0

I have a text file like aaaa aaaa aaaa aaaa .... I use the sed to replace the string of "aaaa" with "bbbb", the command is

sed -i "/aaaa/c\bbbb" mytextfile

but I want the sed to stop processing when it finds first match.The output will be like this bbbb aaaa aaaa aaaa .... Anybody tells how to do that?

Wallace
  • 429
  • 2
  • 18
  • 47

1 Answers1

1

Try the following:

sed '0,/aaaa/{s/aaaa/bbbb/}' mytextfile
Fazlin
  • 2,252
  • 16
  • 29