[Ilugc] Sed should affect the input file

Muthukumar ramana_muthu at yahoo.co.in
Fri Mar 11 14:35:46 IST 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.






More information about the ilugc mailing list