$ 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.
In reply to Re: match a line and edit it
by almut
in thread match a line and edit it
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |