Searching *.gz logs


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Searching *.gz logs
# 8  
Old 08-21-2008
FILES=`ls ./request.log.*.gz` && for F in $FILES; do zgrep "20/Aug/2008:13:50:23" $F; done

or write a script:

Quote:
#!/bin/bash
FILES=`ls ./request.log.*.gz`

for F in $FILES
do
zgrep "20/Aug/2008:13:50:23" $F
done
If it takes forever then that is zgrep reading files the zipped files, not much you can do about that.

By using the "for loop" you do zgrep on one file at a time. This fixes the "bad interpreter: Argument list too long" problem.

Last edited by ddreggors; 08-21-2008 at 01:27 PM.. Reason: Added explaination
# 9  
Old 08-21-2008
Quote:
Originally Posted by openspark
2.zgrep 20/Aug/2008:13:50:23 *
-bash: /usr/bin/zgrep: /bin/sh: bad interpreter: Argument list too long
i told you why that wont work ....
Quote:
Originally Posted by openspark
Please provide any inputs its quite critical !
you just completly disregarded my post
where i tell you the reasoning behind the problem
once you duenrstand the problem, you can walk around it.
to me, it looks like you want us to do all your job for you, and you get paid for it ...
# 10  
Old 08-21-2008
Quote:
Originally Posted by openspark
1.ls | grep \\.gz\$ | xargs zgrep 20/Aug/2008:13:50:23

Takes for ever.
Come on, what do you expect when you are uncompressing thousands of most likely huge log files (otherwise you wouldn't compress them, would you?) and then chasing a grep through them.
As some other bloke replied to you, for this you really require an excessive amount of CPU time slices which probably will hog your box.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Searching exception keyword in all logs in last 5 minutes

Hello Folks , I am a new bie to the world of unix , what i am planning to do is the I have the location in server to which i am access through the putty and the location is /mt/ttlog/avccomn/logs/201901/19 and at this location the files are listed as show startjmsnode1.sh_03.out... (7 Replies)
Discussion started by: punpun26262626
7 Replies

2. Shell Programming and Scripting

If I ran perl script again,old logs should move with today date and new logs should generate.

Appreciate help for the below issue. Im using below code.....I dont want to attach the logs when I ran the perl twice...I just want to take backup with today date and generate new logs...What I need to do for the below scirpt.............. 1)if logs exist it should move the logs with extention... (1 Reply)
Discussion started by: Sanjeev G
1 Replies

3. UNIX Desktop Questions & Answers

regarding logs

Hi , I am running an application on my windows and it logs are generated at /var/logs and for this i have to go this location and then do tail -f , Is there any command you can advise me so that when I execute this command at this location that logs get displayed fully and as the application... (3 Replies)
Discussion started by: KAREENA18
3 Replies

4. Shell Programming and Scripting

searching a file with a specified text without using conventional file searching commands

without using conventional file searching commands like find etc, is it possible to locate a file if i just know that the file that i'm searching for contains a particular text like "Hello world" or something? (5 Replies)
Discussion started by: arindamlive
5 Replies

5. Shell Programming and Scripting

Searching set of string from Live Running Logs

Hey just need one simple syntax to search for the string from the Live Running Logs. The strings are placed in a $infile & everytime the script should pull each string from $infile and should provide as an input for grepping from Live running logs on a rotational basis. So here are the Contents... (14 Replies)
Discussion started by: raghunsi
14 Replies

6. Shell Programming and Scripting

Grep yesterday logs from weblogic logs

Hi, I am trying to write a script which would go search and get the info from the logs based on yesterday timestamp and write yesterday logs in new file. The log file format is as follows: """"""""""""""""""""""""""... (3 Replies)
Discussion started by: harish.parker
3 Replies

7. UNIX for Advanced & Expert Users

logs

Hy, I have a question I have a directory in a unix server, Some of my files have a diffrent access time, from the time i accessed them last, I think some one has copied it,it's not an important file,but none the less,it is my file,It mistakenly had a 777 permission( yes ,I know it is a noob's... (1 Reply)
Discussion started by: lordmod
1 Replies

8. Shell Programming and Scripting

Logs

Hey Guys, i am new into shell programming and i have to do one script which have to record all the commands entered by a specific user. Example of that, i have a system running on unix, several users are using this system, i have to create like a databse which will record every user entered that... (5 Replies)
Discussion started by: charbel
5 Replies

9. UNIX for Dummies Questions & Answers

logs

can i include this command into my crontab file > /var/adm/wtmp to clear the contents on a regular basis ? what about file permissions ? (6 Replies)
Discussion started by: cubicle^dweller
6 Replies

10. UNIX Desktop Questions & Answers

Logs

hi My name is Juan I dont can clear wtmp and similiar files how i do it? thanks (4 Replies)
Discussion started by: jtapia
4 Replies
Login or Register to Ask a Question