how to find a file name that contains a string “abcd ” in the file content from multiple files in the directory using awk

前端 未结 2 1500
情书的邮戳
情书的邮戳 2020-12-22 05:13

the \"bookrecords\" directory has multiple files

bookrecords
           1.txt
           2.txt 
           3.txt .....

file 2.txt has the c

2条回答
  •  时光说笑
    2020-12-22 05:57

    with awk

    $ awk -v search_string="$name" '$0~search_string{print FILENAME; exit}' bookrecords/*
    

    however, I think grep is better if you're not structurally searching

    $ grep -lF "$name" bookrecords/*
    

提交回复
热议问题