LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Other *NIX Forums > Solaris / OpenSolaris
User Name
Password
Solaris / OpenSolaris This forum is for the discussion of Solaris, OpenSolaris, OpenIndiana, and illumos.
General Sun, SunOS and Sparc related questions also go here. Any Solaris fork or distribution is welcome.

Notices


Reply
  Search this Thread
Old 02-13-2008, 03:55 PM   #1
noir911
Member
 
Registered: Apr 2004
Posts: 682

Rep: Reputation: Disabled
[Solaris 9] find and grep entire disk


I am trying to find (text files) on the entire disk & grep for a certain pattern and send the output to a text file. Here's what I am doing -

find / -type f | xargs grep -i "search_me" > find.txt

but this is spitting output/ error on the screen (STDOUT) & not writing anything to the file -

grep: can't open File1
grep: can't open File2
grep: can't open -
grep: can't open File3
grep: can't open Release
grep: can't open Information.doc

I noticed it is giving this error for directories or filenames that have spaces in between. eg. "my file" or "my directory"

Is there anything I could do to the desired result?

Thanks for any help.
 
Old 02-13-2008, 04:18 PM   #2
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,399
Blog Entries: 2

Rep: Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908
how about
Code:
find / -type f -exec grep -i "search_me" {} \; -print > find.txt
--- rod.
 
Old 02-13-2008, 05:30 PM   #3
noir911
Member
 
Registered: Apr 2004
Posts: 682

Original Poster
Rep: Reputation: Disabled
cool works like a charm! didn't know you could use -print after {} \;

Thanks!
 
Old 02-13-2008, 05:51 PM   #4
jlliagre
Moderator
 
Registered: Feb 2004
Location: Outside Paris
Distribution: Solaris 11.4, Oracle Linux, Mint, Debian/WSL
Posts: 9,789

Rep: Reputation: 492Reputation: 492Reputation: 492Reputation: 492Reputation: 492
That variant should run faster:
Code:
find / -type f -exec grep -i "search_me" {} + > find.txt
 
  


Reply



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
can only partition entire disk - help please er20ic Linux - Newbie 2 10-07-2007 02:00 PM
grep -r on a Sun Solaris richikiki Solaris / OpenSolaris 2 08-07-2006 08:12 AM
find for an entire month Koven Linux - Software 7 07-26-2005 10:06 PM
No grep -A possible under Solaris ? markraem Solaris / OpenSolaris 4 11-29-2004 12:29 AM
Make a copy of entire hard disk jeucken Linux - Software 1 03-22-2004 04:55 AM

LinuxQuestions.org > Forums > Other *NIX Forums > Solaris / OpenSolaris

All times are GMT -5. The time now is 03:45 PM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration