Below command searches for all *.txt files in current working directory and then searches for “test-string” word in the file.
find . -name *.txt | xargs grep “test-string"
Below is sample Output.
./test.txt: Port Name: test-string
Or alternatively below command can also be used. Replace /var/log/messages* with filename pattern and restart with search string as needed.
for i in $(ls -art /var/log/messages*);do strings $i|grep 'restart';done
Products to which Article Applies
All Linux Operating Systems
Search Keywords: Linux Unix Grep command commands grepping greping search searching string words file files strings directory directories list listing
Article Author: Tarun Boyella
No comments:
Post a Comment