If you want to check all the files in directory for specific entry this article will help you to find the file. Suppose you have two web server and you take backup of all web code when ever developer do some changes to web file. You store all the backup in one folder. If you want to check which file developers changed particular file. Using below command you can grep all the files at a time, instead of greping/searching file by file.
For example, my backup file location is /data/code-bkp/.
# grep -n ‘array’ /data/code-bkp/*
Where:
-n :- Numbering the lines in that files which contain “array”.
You can also use -l option to just list where your “array” word contains like below.
# grep -l ‘array’ /data/code-bkp/*
Other way if you want to search also sub-directory, you can use -r option like below.
# grep -rn ‘array’ /data/code-bkp/*
If you have any other option please share with us.
Thanks:)
If you find this tutorial helpful please share with your friends to keep it alive. For more helpful topic browse my website www.looklinux.com. To become an author at LookLinux Submit Article. Stay connected to Facebook.
Leave a Comment