in reply to simple text substitution.
Your question has already been answered but I thought someone should clue you in to how -i works and why the suggestion was to use perl -pi -e rather than perl -pie which seems, at first glance, to be the tastier option(s).
The reason the otherwise delectable -pie wasn't suggested was because it wouldn't work.
The -i takes an optional argument. A rather useful argument at that. If given, perl renames the original file by appending the argument as a suffix to the filename, thereby preserving it if you make any mistakes in your one-liner. Trust me. If you use it, you will eventually find this feature useful. If you fail to use it, you will eventually wonder why you didn't. Out of habit, I would write your one-liner as:
perl -pi.bak -e 's/text/newtext/g' /path/to/file
So, anyway, if given -pie perl would is forced to... errrr... eat the 'e' as the backup suffix. Sadly though, "e" isn't usually a very useful suffix.
-sauoq "My two cents aren't worth a dime.";
|
|---|