How to run grep inside awk?

后端 未结 6 2143
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-02-15 11:22

Suppose I have a file input.txt with few columns and few rows, the first column is the key, and a directory dir with files which contain some of these

6条回答
  •  野趣味
    野趣味 (楼主)
    2021-02-15 12:04

    In case you still want to use grep inside awk, make sure $1, $2 etc are outside quote. eg. this works perfectly

    cat file_having_query | awk '{system("grep " $1 " file_to_be_greped")}'
    

    // notice the space after grep and before file name

提交回复
热议问题