Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back > Forums > Linux Forums > Linux - General
User Name
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.


  Search this Thread
Old 05-19-2011, 05:58 PM   #1
Registered: Feb 2007
Location: Scandinavia
Distribution: Centos/Redhat
Posts: 95

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:
 system:    root
When you don't now the location on the file system

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

Rep: Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908
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.
find /some/top/directory -exec grep ' system:    root' {} \; -print
Of course grep itself has the -R 'recursive' switch.
cd grep -R ' system:    root' /some/top/directory/*
--- rod.


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 02:30 AM
fastest way to search for strings niteshadw Linux - Newbie 4 01-30-2010 07:24 AM
Search and replace strings in text files in C Completely Clueless Programming 5 09-15-2009 07:51 PM
How to store text(strings) in a 2D character array reading from a text file(C++) bewidankit Programming 3 02-14-2008 08:08 AM
How to search for text strings? armandino LQ Suggestions & Feedback 2 06-24-2007 08:51 PM > Forums > Linux Forums > Linux - General

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

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