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.
我有两个文件
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
并重新格式化输出