Reputation: 85
If test.txt file is
GREEN Volks RUNNING GREEN Audi STOPPED GREEN Merc RUNNING
I can grep STOPPED and replace it with sed as following
grep "STOPPED" test.txt |sed 's/^GREEN/RED/g'
Which returns following output
RED Audi STOPPED
But instead I would like try something like
sed -i 's/^GREEN/RED/g'| grep "STOPPED" test.txtto see the output as following:
GREEN Volks RUNNING RED Audi STOPPED GREEN Merc RUNNING
Thanks in advance.
Upvotes: 0
Views: 54