SPUG: -pi -e vs. -ni -e

Jeremy Mates jmates at sial.org
Wed Jun 9 03:49:27 CDT 2004


* Aaron W. West <tallpeak at hotmail.com>
> To remove all filenames containing /Temporary Internet Files/ from a
> list of filenames I saved in ~/allfiles:
> 
> $ perl -i -e 'while(<>){print unless /Temporary Internet Files/}' ~/allfiles ; wc allfiles allfiles.bak
>  283986  498823 17066061 allfiles
>  382211 1087456 28422428 allfiles.bak

Looks like you missed the handy -n option, which loops without printing:

perl -ni -e 'print unless /Temporary Internet Files/'

Ni!



More information about the spug-list mailing list