LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   How to find a string inside file in the whole disk (https://www.linuxquestions.org/questions/linux-newbie-8/how-to-find-a-string-inside-file-in-the-whole-disk-677015/)

penguinux 10-17-2008 02:45 AM

How to find a string inside file in the whole disk
 
Hello everyone,

i have to search a particular string inside my disk. is there any command to search a string inside all the files of the disk? can anyone suggest me a command to do so. thanks beforehand.

penguinux

colucix 10-17-2008 02:57 AM

Code:

find / -type f -print0 | xargs -0 grep -i pattern
This command will look for every file in the system and search a (case insensitive) pattern using grep. The file names are passed as arguments through xargs. You have to change the starting point of the search, depending on the mount point of the disk: in my example I put "/" which causes find to search in every little corner of your system.

Just two notes: 1) the command can take a long time, depending on the size of the filesystem, 2) most likely you have to run this command as root, to avoid some permission denied error. See man find, man xargs, man grep for future reference.

penguinux 10-20-2008 07:34 AM

found solution
 
thanks alot..

it solved my problem...


All times are GMT -5. The time now is 07:05 AM.