Find content of one file from another file in UNIX

前端 未结 8 585
攒了一身酷
攒了一身酷 2020-12-01 07:39

I have 2 files. First file contains the list of row ID\'s of tuples of a table in the database. And second file contains SQL queries with these row ID\'s in \"where\" clause

8条回答
  •  北海茫月
    2020-12-01 08:10

    ## reports any lines contained in < file 1> missing in < file 2>

    IFS=$(echo -en "\n\b") && for a in $(cat < file 1>); 
    do ((\!$(grep -F -c -- "$a" < file 2>))) && echo $a; 
    done && unset IFS
    

    or to do what the asker wants, take off the negation and redirect

    (IFS=$(echo -en "\n\b") && for a in $(cat < file 1>); 
    do (($(grep -F -c -- "$a" < file 2>))) && echo $a; 
    done && unset IFS) >> < file 3> 
    

提交回复
热议问题