Sign up ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It's 100% free, no registration required.

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

1 Answer 1

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.