Если я правильно понял, вы хотите сделать две вещи:
#5c616c
на url(#grad1)
. Вставить эти строки после открывающего <svg...>
тега:
<linearGradient id="grad1" x1="0%" y1="0%" x2="100%" y2="0%">
<stop offset="0%" style="stop-color:rgb(255,255,0);stop-opacity:1" />
<stop offset="100%" style="stop-color:rgb(255,0,0);stop-opacity:1" />
</linearGradient>
Лично я бы сделал все на Perl:
#!/bin/perl
my $replacement=<<EoF;
<linearGradient id="grad1" x1="0%" y1="0%" x2="100%" y2="0%">
<stop offset="0%" style="stop-color:rgb(255,255,0);stop-opacity:1" />
<stop offset="100%" style="stop-color:rgb(255,0,0);stop-opacity:1" />
</linearGradient>
EoF
## This is just to fix SE's syntax highlighting /
my $foundSvg = 0;
while (<>) {
## Insert the replacement after the 1st line matching '<svg'
if (/<\s*svg/) {
$foundSvg++;
}
if ($foundSvg == 1) {
## $_ is the value of the current line. If we have found the <svg,
## append $replacement to this line
$_.= $replacement;
## Increment $foundSvg so we don't do this twice
$foundSvg++;
}
## For all lines, replace all occurrences of #5c616c with url(#grad1)
s/#5c616c/url(#grad1)/g;
## Print the line
print;
}
Сохраните это как foo.pl
, а затем:
for f in *svg; do
perl foo.pl "$f" > tmpFile && mv tmpFile "$f"
done
На вашем месте я бы использовал что-то вроде этого:https://en.wikipedia.org/wiki/List_of_collaborative_software#Web-based_software
Управление группами, пользователями и файлами может быстро превратиться в рутинную работу, не говоря уже о том, что это сопряжено с рисками для безопасности и другими сложностями.