guys! I am trying to exchange two words in a line but it doesn\'t work. For example: \"Today is my first day of university\" should be \"my is Today first day of university\"
Try this:
sed -rn 's/(\w+\s)(\w+\s)(\w+\s)(.*)/\3\2\1\4/p' filename.txt
-n suppress automatic printing of pattern space
-r use extended regular expressions in the script
\s for whitespace