Based on How do I prevent sed -i from destroying symlinks?, but I use Perl.
I tried by middle of all these questions:
- Is there a way to make perl -i not clobber symlinks?
- perl symlink on gz file
- How do I prevent sed from destroying hardinks?
It was unsucessfull. Here is the little and simple sample:
#!/bin/perl
use strict; use warnings;
while (<>)
{
## For all lines, replace all occurrences of #5c616c with another colour
s/#5c616c/#8bbac9/g $(readlink -e -- "<>")
## $(readlink -e -- "<>") is similar to --in-place --follow-symlinks
## Print the line
print;
}