LinuxQuestions.org
Visit the LQ Articles and Editorials section
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices

Reply
 
Search this Thread
Old 05-19-2011, 04:58 PM   #1
andy.l
Member
 
Registered: Feb 2007
Location: Scandinavia
Distribution: Fedora Core 6/Ubuntu 6.10
Posts: 92

Rep: Reputation: 15
Search for text strings


What would be the best way to search for a file that contains a string similar to this:
Code:
 system:    root
When you don't now the location on the file system

/Andy
 
Old 05-19-2011, 05:27 PM   #2
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,395
Blog Entries: 2

Rep: Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903
find can be your friend any time you need to do a recursive filesystem search. On a large filesystem, you'll do yourself a favor by at least having some dea where to start looking; even automated tools can get bogged down in hundreds of gigabytes of files.
Code:
find /some/top/directory -exec grep ' system:    root' {} \; -print
Of course grep itself has the -R 'recursive' switch.
Code:
cd grep -R ' system:    root' /some/top/directory/*
--- rod.
 
  


Reply


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 On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] How do I search for for text between difficult strings, like"yellow"/></w:rP..." dsayars Programming 5 07-22-2010 01:30 AM
fastest way to search for strings niteshadw Linux - Newbie 4 01-30-2010 06:24 AM
Search and replace strings in text files in C Completely Clueless Programming 5 09-15-2009 06:51 PM
How to store text(strings) in a 2D character array reading from a text file(C++) bewidankit Programming 3 02-14-2008 07:08 AM
How to search for text strings? armandino LQ Suggestions & Feedback 2 06-24-2007 07:51 PM


All times are GMT -5. The time now is 05:27 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