Write a command to switch the two consecutive words “apple” and “mango” in a file?

sed ‘s/\(apple\) \(mango\)/\2 \1/’ < filename

Category: UNIX Interview Questions.