I want to edit the original files with perl, when I have a numeric sequence of aliases.
The task is to use perl on the command line, e.g.
perl -pe 's/apples/oranges/' But to edit files in place:
perl -i.bak The -i option does not work with symbolic links
ln -s fs fruitSalad With -i, perl will re-write a new file, replacing (clobbering) the prior symbolic link. i.e. it does not edit original.
There's a workaround (https://unix.stackexchange.com/questions/9318/is-there-a-way-to-make-perl-i-not-clobber-symlinks) which is like this:
perl -i.bak -pe 's/apples/oranges/' $(readlink fs) Here's my problem. I want to edit in-place, the original files from a sequence of symbolic links.
ln -s fs.1 fruitSalad-1 ln -s fs.2 fruitSalad-2 With normal files, perl will work with ranges, e.g.
perl -i.bak -pe 's/apples/oranges/' fs.{1..2} But that does not work with the $(readlink __) trick. It's not possible to combine the above, and I prefer to avoid xargs.
Any idea how to edit ranges of files via their symbolic links from the command line? What am I missing?