in reply to delete a line


Here are some one-liners to delete a line or replace a portion of a line in a file. The command line options are explained in perlrun
# 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
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).

--
John.