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"
This is what I tried:
sed 's/\([a-zA-z0-9]\)\([a-zA-z0-9]\)\([a-zA-z0-9]\)/\3\2\1/' filename.txt
What am I doing wrong?
Best Answer
Try this one:
Your problem is that you're tryng to use extended regex without
-r
option or escape symbol in sed command.Also the regex isn't fully correct.
You're specifying incorrect range: there is no
A-z
range, there isA-Z
.Also you forgot spaces and you didn't specify that words are multicharacter.