Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
次のような2つのファイルがあります
1 2 1 3 1 4 2 3 2 6
と
3 1 6 2 1 4
フィールドの順序が重要でfile2ない場所で行を見つけたいと思います。file1出力は次のようになります。
file2
file1
1 2 2 3
で試してみましawk 'FNR==NR{a[$0];next}!($0 in a)' file1 file2たが、フィールドが逆だとうまくいかないと思います。
awk 'FNR==NR{a[$0];next}!($0 in a)' file1 file2
フィールドの順序が問題にならないようにするための小さな変更:
$ awk 'FNR==NR{a[$1" "$2];next}!($1" "$2 in a||$2" "$1 in a)' file2 file1 1 2 2 3
file2注:最初に与える必要があります。
sdiff -s file1 file2
出力を再フォーマットします