Given I have a file with several words, how can I do the following:

How can I replace AAA for BBB in a file with Unix?

  • 2
    sed -i.bak 's/AAA/BBB/g' – Kevin Jan 31 '13 at 19:02
  • 3
    I downvoted the question, because it didn't show any research effort. – Bernhard Jan 31 '13 at 19:05
sed s/AAA/BBB/g input.txt > output.txt

You can then check output.txt and copy it over input.txt. Learn more about sed here.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.