LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Other *NIX Forums > Other *NIX
User Name
Password
Other *NIX This forum is for the discussion of any UNIX platform that does not have its own forum. Examples would include HP-UX, IRIX, Darwin, Tru64 and OS X.

Notices


Reply
  Search this Thread
Old 05-12-2005, 09:20 AM   #1
xtremexp
LQ Newbie
 
Registered: May 2005
Posts: 1

Rep: Reputation: 0
"grep" Command (SystemV/68 system)


How can i use grep command in order to look for into subdirectories?
I want to searche some word in a folder and in all its sub-directories in the same time.
(my system is based on "SystemV/68 R3V6"(UNIX))
Note:
1) "rgrep" program isn't installed on my system
2)-r option is not available ("grep -r" doesn't work)
Available options i got are: -b -l -n -s -v -i
 
Old 05-12-2005, 10:34 AM   #2
Technoslave
Member
 
Registered: Dec 2003
Location: Northern VA
Posts: 493

Rep: Reputation: 30
If r isn't any option, much like on Solaris, what you'll end up doing is this:

grep -i blah *
grep -i blah */*
grep -i blah */*/*

Until there are no more sub directories, or there are so many subdirectories that grep doesn't work anymore.
 
Old 05-14-2005, 12:45 AM   #3
btmiller
Senior Member
 
Registered: May 2004
Location: In the DC 'burbs
Distribution: Arch, Scientific Linux, Debian, Ubuntu
Posts: 4,290

Rep: Reputation: 378Reputation: 378Reputation: 378Reputation: 378
Assuming your find has the -exec switch, you should also be able to do:

find . -name "*" -exec grep whatever /dev/null {} \;

The /dev/null is to give grep two arguments to force it to print the file name of matching lines.
 
Old 05-28-2005, 07:25 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 one will run faster, and doesn't need a /dev/null hack.
Code:
find . -type f -exec grep whatever {} +
If the "+" flag is unsupported by SVR3 find, use instead
Code:
find . -type f | xargs grep whatever

Last edited by jlliagre; 05-28-2005 at 07:31 PM.
 
  


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
About SElinux: enter "setenforce 0",system complains bad command aladin Linux - Software 3 08-21-2005 08:16 PM
How to use "OR" option in a grep command. sumitarun Programming 3 04-18-2005 01:44 AM
where is command "cd" located? or is it a command/ system call? feetyouwell Linux - Software 5 10-01-2004 08:01 PM
"X-MS" cant open because "x-Multimedia System" cant access files at "smb&qu ponchy5 Linux - Networking 0 03-29-2004 11:18 PM
"Undeleting" data using grep, but get "grep: memory exhausted" error SammyK Linux - Software 2 03-13-2004 03:11 PM

LinuxQuestions.org > Forums > Other *NIX Forums > Other *NIX

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

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