Differences between version 11 and revision by previous author of PerlOneLiners.
Other diffs: Previous Major Revision, Previous Revision, or view the Annotated Edit History
Newer page: | version 11 | Last edited on Tuesday, December 16, 2003 5:33:40 pm | by JohnMcPherson | Revert |
Older page: | version 10 | Last edited on Tuesday, December 16, 2003 4:59:49 pm | by GreigMcGill | Revert |
@@ -22,7 +22,10 @@
!! 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 perl -n (for no print) and then does an explicit print.) This could be rewritten as:
+ perl -pe 's@\\n@\012@g; s@\\t@\011@g' < $file
+(you can use any punctuation as the separator in an s/// command, and if you have \ chars in your regexp then doing this can increase clarity.)
----
AddToMe