これは私が達成しようとしているものです:
ファイル1:
test fileb 4578;
test filec 7689;
test filey 9978;
test filez 12300;
ファイル2:
test fileb 1;
test filec 2;
test filey 3;
file1 は次のようになります。
test fileb 1;
test filec 2;
test filey 3;
test filez 12300;
% awk 'NR==FNR{a[$1,$2]=$3;next}{if(a[$1,$2])$3=a[$1,$2];print}' file2 file1
test fileb 1;
test filec 2;
test filey 3;
test filez 12300;
あなたが試すことができます:
while read f1 f2 f3
do
X=$(grep "$f1 $f2" file2)
if [ -n "$X" ]; then
echo "$X"
else
echo "$f1 $f2 $f3"
fi
done <file1
これはうまくいくかもしれません(GNU sed):
sed 's|\(\S* \S*\).*|/\1/c\\&|' file2 | sed -i -f - file1