[Ilugc] Sed should affect the input file

  • From: ramana_muthu@xxxxxxxxxxx (Muthukumar)
  • Date: Fri Mar 11 14:36:08 2005


What is the option should I need to set, so that the replacement string
should affect the Input file

Example:
        sed 's/<old>/<new>/g' input_file
Then If I open input_file the file the effect should take place in the
input file.

Is it possible to do that?

We can do with PERL directly as,

perl -pi -e 's<old>/<new>/g' input_file

so that pattern matching changes will be updated in the same input_file.

To accomplish with sed then,

sed 's/<old>/<new>/g' input_file > outputfile; mv outputfile input_file

HTH.

Thanks,
-Muthukumar.




Other related posts: