Awk oneliner to find a string in text files

If you want to know the name of files containing a special string, grep -c is your friend. But you also get names of files not containing your string (with count = 0). If you only want the names of files containing “mystring”, awk can help you: grep -c "mystring" * | awk ' !/:0/ ' And if you don’t even want the number of times “mystring” appears (on 1 line): ...

December 1, 2008 · 1 min · jepoirrier