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.
我想打印二进制结果,file1因为值是匹配的file2:
file1
file2
文件1:
a b c d 1 2 9 4 5 6 7 8 4 3 0 1 8 9 6 5
文件2:
x 1 2 3 4 5 6 7 8
预期成绩:
a b c d 1 1 0 1 1 1 1 1 1 1 0 1 1 0 1 1
x通过将 column infile2与所有列a, b, c, din匹配file1。我想在Result文件中打印二进制结果。
x
a
b
c
d
Result
这可以解决问题:
awk 'FNR==NR{if(NR>1)a[$1];next}FNR>1{for(i=1;i<=NF;i++)$i in a?$i=1:$i=0}1' f2 f1 a b c d 1 1 0 1 1 1 1 1 1 1 0 1 1 0 1 1
你的和分别在哪里f2和是。f1file2file1
f2
f1