Grep from different folder


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Grep from different folder
# 1  
Old 08-16-2006
Grep from different folder

Hi All,

Need your assistance/advice.

I have 4 folders but using same name log file.

/user/access/server1
/user/access/server2
/user/access/server3
/user/access/server4

filename is access.log.20060716.gz

I want to grep the transaction id in the log file but I want to do simultaneously instead do 4 times.

Normal i did like this; gzcat access.log.20060716.gz | grep txid=1234567

Hope anyone can help me.
# 2  
Old 08-16-2006
It's not clear to me where the 4 folders come into the equation. Does the log file exist in all folders? ( There are 4 copies of the log file, one in each folder? )

If so, you can do something like
Code:
gzcat folder1/logfile.gz folder2/logfile.gz ... | grep expression

Or you can decompress the files and do
Code:
grep expression folder1/logfile folder2/logfile ...

# 3  
Old 08-16-2006
Thanx bro!!! It's work. Smilie
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Grep date pattern folder and zip -->delete

Hi All, OS: Redhat Linux 7.5 Shell: Bash I have some folder like this 2018-09-16 2018-09-17 2018-09-18 2018-09-19 and so on... Everyday one script create a folder with pattern YYYY-MM-DD (it will have so many sub directories files in it) Now what I would like to achieve is a... (1 Reply)
Discussion started by: onenessboy
1 Replies

2. Shell Programming and Scripting

Delete oldest folder based on folder named as date

Hi, I have a script doing backup to synology server, the script create new folder each day with the date as being folder name i.e. 2018-07-30. Just before creating the new folder I want the script to find the oldest folder from the list and delete it including its content. for example... (3 Replies)
Discussion started by: humble_learner
3 Replies

3. Shell Programming and Scripting

Request for Shell script to move files from Subfolder to Parent folder and delete sub folder

Hi Team, I am new to shell script and there is a requirement where files should be moved from Subfolder to parent folder. Eg: parent folder --> /Interface/data/test/IN Sub folder -->/Interface/data/test/IN/Invoice20180607233338 Subfolder will be always with timestamp... (6 Replies)
Discussion started by: srivarun15
6 Replies

4. Shell Programming and Scripting

Shell scripting for moving folder specific files into target directory of that country folder.

I need help to write shell script to copy files from one server to another server. Source Directory UAE(inside i have another folder Misc with files inside UAE folder).I have to copy this to another server UAE folder( Files should be copied to UAE folder and Misc files should be copied in target... (3 Replies)
Discussion started by: naresh2389
3 Replies

5. UNIX for Dummies Questions & Answers

Grep with parent folder

Hi, When I do ls -l | grep -h STRING I need not only to get those files, but also the parent folder of those files, no idea how do that. BTW the names of those parent folders are never longer than 3 digits, if that helps. Any assistance most welcome, /bw, OmarKN Please... (9 Replies)
Discussion started by: OmarKN
9 Replies

6. UNIX for Dummies Questions & Answers

Search current folder and subfolders with grep

Hello, Neither ‘Grep -r' nor ‘grep -R' is working in my environment. (Searching for a text pattern in the files) Any suggestions... Using SunOS 5.9 Thanks, Trinanjan. (1 Reply)
Discussion started by: bhanja_trinanja
1 Replies

7. UNIX for Advanced & Expert Users

grep for entire line from a log folder

As per my understanding below mentioned line of code finding a word 'boy' in $ACULOG... num_errors=`grep -i -e fail -e illegal -e exception -e "<E" -e boy $ACULOG | wc -l` if I'm not corerct, please correct me. How I can find entire line like "This is a boy" with something similar as above... (1 Reply)
Discussion started by: heyitsmeok
1 Replies

8. Shell Programming and Scripting

File Management: How do I move all JPGS in a folder structure to a single folder?

This is the file structure: DESKTOP/Root of Photo Folders/Folder1qweqwasdfsd/*jpg DESKTOP/Root of Photo Folders/Folder2asdasdasd/*jpg DESKTOP/Root of Photo Folders/Folder3asdadfhgasdf/*jpg DESKTOP/Root of Photo Folders/Folder4qwetwdfsdfg/*jpg DESKTOP/Root of Photo... (4 Replies)
Discussion started by: guptaxpn
4 Replies

9. UNIX for Dummies Questions & Answers

Execute grep command within a folder

Experts, i need your help to made an enhance query using the existing one. i'm using a command "find . -exec grep -l 'search string' {} \;" to search a particular sting within the file within a folder. Basically, my idea is to fine tune my search. What i want is, instead of searching all files... (2 Replies)
Discussion started by: gav_dhiman
2 Replies

10. UNIX for Dummies Questions & Answers

grep multiple text files in folder into 1 text file?

How do I use the grep command to take mutiple text files in a folder and make one huge text file out of them. I'm using Mac OS X and can not find a text tool that does it so I figured I'd resort to the BSD Unix CLI for a solution... there are 5,300 files that I want to write to one huge file so... (7 Replies)
Discussion started by: coppertone
7 Replies
Login or Register to Ask a Question