in reply to match a line and edit it
$ perl -i.bak -pe 's/^.*foo.*$/bar/' file
"foo" is the pattern to search for in the line. The whole line will be replaced with "bar". -p is equivalent to putting while (<>) { ...; print } around the code. -i.bak does "in-place" editing, creating a backup file with extension .bak.
|
|---|