Differences between version 2 and previous revision of PerlOneLiners.
Other diffs: Previous Major Revision, Previous Author, or view the Annotated Edit History
Newer page: | version 2 | Last edited on Wednesday, August 27, 2003 12:57:40 pm | by PhilMurray | Revert |
Older page: | version 1 | Last edited on Wednesday, August 27, 2003 12:55:41 pm | by PhilMurray | Revert |
@@ -1,12 +1,12 @@
-__Removing empty lines from a file
+__Removing empty lines from a file__
-perl -ni.bak -e 'print if /\S/' file1 file2
+
perl -ni.bak -e 'print if /\S/' file1 file2
--i means perl will edit he
file in place and save a backup with .bak extension
--e means execute the code/command in the quotes
--n read man
perlrun
+;
-i :
means perl will edit the
file in place and save a backup with the
.bak extension
+;
-e :
means execute the code/command in the quotes
+;
-n :
read the manpage
perlrun(1) for this one
The command will loop through the files you specify and print out the lines (into the file you specified) if they match the RegularExpression /\S/
AddToMe