egrep 'TextToFind' certainSubFolders/*.abc


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers egrep 'TextToFind' certainSubFolders/*.abc
# 1  
Old 03-24-2011
egrep 'TextToFind' certainSubFolders/*.abc

Hi,

I'm trying to do the following and can't figure out how to achieve it.

On my computer there are a number of folders called 'program' at various levels.

I would like to search for these folders (that are below my current level) and then use egrep to search for a string within files that have a certain extension.

Thanks for any advice!

js

By the way, I'm using Solaris and the csh shell...
# 2  
Old 03-24-2011
Use the find command
Code:
find ./ -type d -name "*program*"

# 3  
Old 03-24-2011
Hi ctsgnb,

Thanks for that. I'm a complete newbie and so am now wondering how I can link the find command up with the egrep command, so that only the directories in the find results will be grepped.

Thanks!

js
# 4  
Old 03-24-2011
the find command will already only display directory with a name matching *program*
# 5  
Old 03-24-2011
OK. Thanks.

I actually knew about the find command before. My difficulty is getting the whole process done without having to manually feed in the found directories.

Anyone?

Cheers
# 6  
Old 03-24-2011
Code:
find ./ -type d -name "*program*" | while read a
do
    grep -l PATTERN $a/*.ext
done

This User Gave Thanks to ctsgnb For This Post:
# 7  
Old 03-24-2011
Hi Ctsgnb, Thanks for all the help. I really appreciate it.

Just in case anyone else is trying to run the above, you have to use Bash or Korn Shell.

Cheers

Last edited by js8765; 03-24-2011 at 08:42 AM..
 
Login or Register to Ask a Question

Previous Thread | Next Thread

8 More Discussions You Might Find Interesting

1. AIX

Rootvg /abc file is full

In rootvg /abc file is full,I want to increase,but there is no free pps,how will u do it? (1 Reply)
Discussion started by: ramraj731
1 Replies

2. Shell Programming and Scripting

get value between <abc and > by perl, awk

Hi Everyone, cat 1.txt a <abc b vfff c 000> d 4444 the output is: <abcvfff000> by using perl or awk, can get the value betwee "<abc" and ">", assume 1.txt has lots of those tags, so the output can filter out all those values. Please advice. Thanks (4 Replies)
Discussion started by: jimmy_y
4 Replies

3. UNIX for Dummies Questions & Answers

Replace 'abc' with 'xyz'

Hi everyone I am new to unix . i got struck up with small issue. i have text file something like this abc 'xyz' '5' pqr 'lmn' '6' i want to replace abc 'xyz' '5' with abc 'tyr' '9' but i know the key 'xyz' based on the key 'xyz' i want to replace please help me . its... (3 Replies)
Discussion started by: Vijayaragavan
3 Replies

4. Shell Programming and Scripting

Increment ABC-123 by 1!!

in a shell script, i hav a variable declared as "ABC-123". i want to incriment th value ABC-123 by 1 so that the result will be ABC-124. Can anyone suggest a solution in shell scripting.. (4 Replies)
Discussion started by: pgmfourms
4 Replies

5. Shell Programming and Scripting

What is difference between ./abc.sh and . abc.sh

Hi Friends I have one shell script abc.sh If I run it ./abc.sh and . abc.sh , then what is the difference.. Thanks Joy:confused: (1 Reply)
Discussion started by: itsjoy2u
1 Replies

6. Shell Programming and Scripting

String start with ABC

Hi, How to find out the words starting with ABC in a file (K shell) I dont want the word having ABC in middle of any string. Thanks Subrat (1 Reply)
Discussion started by: subrat
1 Replies

7. UNIX for Dummies Questions & Answers

Egrep cheat sheet anywhere? Looking for meaning of egrep -c

Hi I've been searching google and have not found what egrep -c means. Does anyone know where I can get a cheat sheet or what that -c means? thanks, Linda (2 Replies)
Discussion started by: leelm
2 Replies

8. Shell Programming and Scripting

how to make ABC into "ABC" ina file

suppose u have a file ABC CDF ADF FDG HAA AHH AHA so output shud be like "ABC" "CDF" "ADF" FDG " "HAA" "AHH" "AHA" (8 Replies)
Discussion started by: cdfd123
8 Replies
Login or Register to Ask a Question