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
  • 561
  • 2
  • 21
  • 54

1 Answers1

1

Try the following:

sed '0,/aaaa/{s/aaaa/bbbb/}' mytextfile
Fazlin
  • 2,285
  • 17
  • 29