Today I found the task to change all occurences of a string in some of a larger sum of files and remembered perlrun, which I don't do very often. After having backupped all files in question (which proved to be a good idea later), I did a
perl -pi -e 's/(:Timeplaner):Projekt,/$1$1,/' *
and naively expected it to change the 115 (out of 432) files that needed the change.
But of course it did more than just that.
All files were changed, and their old access date was lost (read: except for in the backup, d'oh!).
Now I am wondering what would be the nicest way of doing the task to only change those files actually containing the string I am looking for, leaving the others untouched and still use something comparatively simple as perl -pi?
Cheers, Sören
In reply to "Change, but don't touch" or naive use of perl -pi by Happy-the-monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |