user3427690
user3427690

Reputation: 81

how to search a string in multiple files in 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.

Upvotes: 4

Views: 26102

Answers (2)

user1400890
user1400890

Reputation: 71

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

Upvotes: 7

krzysiek.ste
krzysiek.ste

Reputation: 2276

Probably you see that server is hanging up because there are a lot of files and it need time to search required word or can't find it because required string doesn't exist

grep -r "parcel" /directory

is correct command to search string under given directory.

Upvotes: 2

Related Questions