Link to home
Create AccountLog in
Avatar of vishali_vishu
vishali_vishu

asked on

find all the files which contains a specified string starting from one root directory.

Hai !
       I have a root directory and under that directory i have thousands of sub directory and files.

My task is to find all the files starting from the root directory and search all the files in the sub directories and sub sub directories and list all the files which have a specified string. ( string will be given as input)
Avatar of omarfarid
omarfarid
Flag of United Arab Emirates image

Try

find / -print | xargs grep string
Homework?
Avatar of vishali_vishu
vishali_vishu

ASKER

what does xargs do in brief ?
it takes the output of the previous command (find) and run grep string on the files one by one
ASKER CERTIFIED SOLUTION
Avatar of omarfarid
omarfarid
Flag of United Arab Emirates image

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
You may want to check files only, so change it to

find / -type f -print | xargs grep string