Hi,
Quote:
Originally Posted by linux_kung_fu
awk would be fine, however that appears to write that to stdout. How would I get it to commit the changes to 'infile'? Thanks!
|
Awk doesn't have a -i option like sed does, you need an extra command:
Code:
awk '!/string/ { sub(/10.0.0.1/,"254.254.254.254")} { print }' infile > outfile
mv outfile infile
The awk command puts its output in
outfile, the mv command moves it to
infile (the original will be lost!!).
Can also be written on one line:
Code:
awk '!/string/ { sub(/10.0.0.1/,"254.254.254.254")} { print }' infile > outfile ; mv outfile infile
Hope this helps.