How To Search Multiple Files Using GREP

search-multiple-files-using-grep
mm
Written By:- Santosh Prasad

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:)

About Author

mm

Santosh Prasad

Hi! I'm Santosh and I'm here to post some cool article for you. If you have any query and suggestion please comment in comment section.

Other Post by Santosh Prasad

Visit All Post

Related Article

You may also Like

Leave a Comment

Shares