1
How can I replace all the same phrases within a file, using Bash Shell Script, when receiving the value to be replaced from a variable?
1 - How I would like - but it doesn’t work.:
txtSalt="frase-que-sera-substituida"
perl -i -pe'
BEGIN {
@chars = ("a" .. "z", "A" .. "Z", 0 .. 9);
push @chars, split //, "!@#$%^&*()-_ []{}<>~\`+=,.;:/?|";
sub salt { join "", map $chars[ rand @chars ], 1 .. 64 }
}
s/$txtSalt/salt()/ge
' meuarquivo.php
2 - How it works - with the phrase applied directly.:
perl -i -pe'
BEGIN {
@chars = ("a" .. "z", "A" .. "Z", 0 .. 9);
push @chars, split //, "!@#$%^&*()-_ []{}<>~\`+=,.;:/?|";
sub salt { join "", map $chars[ rand @chars ], 1 .. 64 }
}
s/frase-que-sera-substituida/salt()/ge
' meuarquivo.php