Inner join on two text files

前端 未结 5 2045
陌清茗
陌清茗 2020-11-22 05:06

Looking to perform an inner join on two different text files. Basically I\'m looking for the inner join equivalent of the GNU join program. Does such a thing exist? If not,

5条回答
  •  伪装坚强ぢ
    2020-11-22 05:42

    You may modify this script:

    cat file2 | while read line; do
        grep $line file1 # or whatever you want to do with the $line variable
    done
    

    while loop reads file2 line by line and gives that line to the grep command that greps that line in file1. There're some extra output that maybe removed with grep options.

提交回复
热议问题