|
|
Three Tips
Heya, this is something I do ALL the time - glad that someone thought about submitting it.
I have a couple tips for doing this, though: 1) If you think you would like to keep a backup of the file(s) that you are doing this to, you can put an extension after the 'i' option, like this: perl -pi.bak -e 's/foo/bar/g' filename This will rename the original file to filename.bak before doing the search/replace. 2) You can search case-insensitively with 's/foo/bar/gi' 3) You can change the line endings to Unix style like this: perl -pi -e 's/r//g' filename Mr. Sharumpe
careful ...
From examples shown above, it will replace all words containing "foo" with "...bar...". For example, "fool" --> "barl", etc. To change word "foo" to "bar", use the following syntax for the regular expression:
careful ...
Hey Rob, will the new geeklog stop robbing code fragments of their backslashes? Both parent and grandparent of this post have lost such symbols, rendering the code somewhat silly!
careful ...
I surrender!
careful ...
Hmm .. The preview showed the "<back slash>b", but I can see that my post lost the <backslash>. |
SearchFrom our Sponsor...Latest Mountain Lion HintsWhat's New:HintsNo new hintsComments last 2 daysLinks last 2 weeksNo recent new linksWhat's New in the Forums?
Hints by TopicNews from Macworld
From Our Sponsors |
|
Copyright © 2014 IDG Consumer & SMB (Privacy Policy) Contact Us All trademarks and copyrights on this page are owned by their respective owners. |
Visit other IDG sites: |
|
|
|
Created this page in 0.14 seconds |
|