Penguin
Diff: PerlOneLiners
EditPageHistoryDiffInfoLikePages

Differences between version 20 and predecessor to the previous major change of PerlOneLiners.

Other diffs: Previous Revision, Previous Author, or view the Annotated Edit History

Newer page: version 20 Last edited on Wednesday, June 9, 2004 4:38:04 pm by CraigBox Revert
Older page: version 19 Last edited on Friday, April 9, 2004 11:37:38 am by AristotlePagaltzis Revert
@@ -1,7 +1,13 @@
 Many oneliners rely on the magic of [Perl]'s __-i__ switch, which means when files supplied on the commandline are opened they are edited in place, and if an extension was passed, a backup copy with that extension will be made. __-e__ specifies the [Perl] code to run. See perlrun(1) for any other switches used here - in particular, __-n__ and __-p__ make powerful allies for __-i__. 
  
 The unsurpassed power of [Perl]'s RegularExpression flavour contributes a great deal to the usefulness of nearly every oneliner, so you will also want to read the perlretut(1) and perlre(1) manpages to learn about it. 
+  
+!! Perl pie  
+  
+ perl -pi -e 's/foo/bar/' file  
+  
+Does an inplace sed on the file. [GNU] sed(1) v4 also supports this with -i.  
  
 !! Removing empty lines from a file 
  
  perl -ni.bak -e'/\S/ && print' file1 file2