in reply to delete a line
The -i.bak option makes the changes in-place and saves a back-up to file.bak. If you are sure that your filter is correct you can omit the .bak part and skip the backup (use with care).# Remove the third line in the file perl -i.bak -ne 'print unless $. == 3' file # Remove any lines that contain foo perl -i.bak -ne 'print unless /foo/' file # Remove foo from all lines perl -i.bak -pe 's/foo//g' file # Substitute foo with bar on all lines perl -i.bak -pe 's/foo/bar/g' file
--
John.
|
|---|