[Ilugc] Multiple find and replace in a text file

  • From: baskar@xxxxxxxxxxxx (Baskar Selvaraj)
  • Date: Mon, 9 Dec 2013 06:49:56 +0530

On Mon, Dec 9, 2013 at 2:08 AM, Shrinivasan T <tshrinivasan at gmail.com>wrote:

I have a huge text file. example: huge-text.csv

I have to find and replace multiple strings example: strings.txt

cat strings.txt

one = {{ONE}}
PP = {{Public Park}}
ok = {{Okey}}


sed should be enough for the above work.

sed -e 's/one/{{ONE}}/g' -e 's/PP/{{Public Park}}/g' -e 's/ok/{{OKey}}/g'
strings.txt

Use -i after sed for 'inplace' editing within the file, else it will just
display the contents.

S.Baskar

Other related posts: