Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question
sed -i.bak 's/AAA/BBB/g' – Kevin Jan 31 '13 at 19:02
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.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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