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

后端 未结 2 1145
-上瘾入骨i
-上瘾入骨i 2021-02-07 23:26

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:41

    if grep -Fqvf file2 file1; then
        echo $"There are lines in file1 that don’t occur in file2."
    fi
    

    Grep options mean:

    -F, --fixed-strings       PATTERN is a set of newline-separated fixed strings
    -f, --file=FILE           obtain PATTERN from FILE
    -v, --invert-match        select non-matching lines
    -q, --quiet, --silent     suppress all normal output
    

提交回复
热议问题