Penguin
Diff: PerlOneLiners
EditPageHistoryDiffInfoLikePages

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

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

Newer page: version 18 Last edited on Friday, April 9, 2004 11:33:23 am by AristotlePagaltzis Revert
Older page: version 15 Last edited on Friday, April 9, 2004 11:30:40 am by AristotlePagaltzis Revert
@@ -5,10 +5,11 @@
 !! Removing empty lines from a file 
  
  perl -ni.bak -e'/\S/ && print' file1 file2 
  
-In Shell:  
- for FILE in file1 file2 ; do mv "$F"{,.bak} ; sed '/ ^ *$/d ' < "$F.bak" > "$F" ; done 
+In [ Shell] :  
+  
+ for FILE in file1 file2 ; do mv "$F"{,.bak} ; grep '[[ ^ ] ' "$F.bak" > "$F" ; done 
  
 !! Collapse consecutive blank lines to a single one 
  
  perl -00 -pi.bak -e1 file1 file2 
@@ -19,16 +20,12 @@
  
  perl -e 'printf "%08b\n", $_ for unpack "C*", shift' 'My String' 
  
 !! Replace literal "\n" and "\t" in a file with newlines and tabs 
-  
- cat $file | perl -ne 's/\\n/\012/g; s/\\t/\011/g; print'  
-  
-This has a useless use of __cat__, and uses __-n__ but then does an explicit print. You also don't need to use octal-coded character codes. It should be rewritten as:  
  
  perl -pe 's!\\n!\n!g; s!\\t!\t!g' $file 
  
-You can use any punctuation as the separator in an __s///__ command, and if you have backslashes or even need literal slashes in your pattern then doing this can increase clarity. 
+Note that you can use any punctuation as the separator in an __s///__ command, and if you have backslashes or even need literal slashes in your pattern then doing this can increase clarity. 
  
 !! List all currently running processes 
  
 This is useful if you suspect that ps(1) is not reliable, whether due to a RootKit or some other cause. It prints the process ID and command line of every running process on the system (except some "special" kernel processes that lie about/don't have command lines).