I'd use perl
:
perl -ne '
BEGIN{
local $/ = undef;
$template = <STDIN>; # slurp file B in
}
chomp;
print $template =~ s/\bvalue1\b/$_/gr' fileA < fileB
If your version of perl
is too old to support the r
substitute flag, you can use a temporary variable:
perl -ne '
BEGIN{
local $/ = undef;
$template = <STDIN>; # slurp file B in
}
chomp;
($out = $template) =~ s/\bvalue1\b/$_/g;
print $out' fileA < fileB