Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to search a string in multiple files in unix

Tags:

linux

unix

I want to search a string in the directory (sub directories too) /www/mydirectory, the string is parcel. I have tried with the command grep -r "parcel". i got this from stackoverflow. But if i give this command, server is hanging up and displays nothing. Please help me in getting this.

like image 266
user3427690 Avatar asked Sep 20 '25 02:09

user3427690


1 Answers

Use this command

grep -nr "PARCEL" /var --color*

-n for printing line number within the file

-r searches recursively in sub-dirs as well

/var is the top-level path from which the search is done recursively in all the sub-dirs & files

--color highlights the grep'ed string in the output

like image 76
user1400890 Avatar answered Sep 22 '25 23:09

user1400890