Check if all lines from one file are present somewhere in another file

后端 未结 2 1234
北海茫月
北海茫月 2021-02-07 23:35

I used file1 as a source of data for file2 and now I need to make sure that every single line of text from file1 occurs somewhere

2条回答
  •  死守一世寂寞
    2021-02-07 23:50

    You can try

    awk -f a.awk file1 file2
    

    where a.awk is

    BEGIN { IGNORECASE=1 }
    NR==FNR {
        a[$0]++
        next
    }
    {
        for (i in a) 
            if (index($0,i)) 
                delete a[i]
    }
    
    END {
        for (i in a)
            print i
    }
    

提交回复
热议问题