LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices

Reply
 
Search this Thread
Old 10-17-2008, 02:45 AM   #1
penguinux
LQ Newbie
 
Registered: Sep 2008
Posts: 4

Rep: Reputation: 0
Question 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
 
Old 10-17-2008, 02:57 AM   #2
colucix
Moderator
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,488

Rep: Reputation: 1956Reputation: 1956Reputation: 1956Reputation: 1956Reputation: 1956Reputation: 1956Reputation: 1956Reputation: 1956Reputation: 1956Reputation: 1956Reputation: 1956
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.
 
Old 10-20-2008, 07:34 AM   #3
penguinux
LQ Newbie
 
Registered: Sep 2008
Posts: 4

Original Poster
Rep: Reputation: 0
Smile found solution

thanks alot..

it solved my problem...
 
  


Reply

Tags
disk, files, find, inside, string


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to find a match string in conf file Ameii83 Linux - Newbie 6 08-12-2008 07:42 PM
how to find out particular string in a file mksc Linux - Newbie 1 06-23-2008 03:04 AM
Shell script: how to find a file containing a string guarriman General 2 08-27-2007 03:39 AM
find inside file maac2282 Linux - Desktop 2 05-20-2007 09:40 AM
find a texte inside a unknow file guano Linux - General 1 03-29-2004 10:14 AM


All times are GMT -5. The time now is 09:16 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration