Help finding info from log file


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Help finding info from log file
# 1  
Old 03-18-2011
Help finding info from log file

Hi,

I have a log file that contains information such as this:

date
id number
command1
command2
command3
command4
data
data
data

date
id number
command1
command2
command3
command4
data
data
data
...and so on.

I need to find every time command3 was sent for a specific date. So I need to grep on 'this specific date' and 'command3' and send it to a log file. Is there a way to grep or awk down?
# 2  
Old 03-18-2011
Yes it is possible, but pls give more clue :

How is the date formatted ? give an example of date you want to query
Which command you want to look for that specific date ?

Please give a "real-like" example of input you have and output you need, then people will be able to provide an accurate help.
# 3  
Old 03-18-2011
Ok, sorry for not giving more.

Let's say the log file has this. The end of each entry is separated by a blank line and then the other command string is sent is displayed:

03/17/2011
id number
command1
command2
command3
command4
data
data
data
<blank line>
03/18/2011
id number
command1
command2
command3
command4
data
data
data
<blank line>
03/18/2011
id number
command1
command2
command3
command4
data
data
data

I want some code to do something like:

Read history.log
date=03/18/2011
commandissued=command4
where $date and $commandissues occurs in the same entry (in between blank lines> execute a count and display the results.

Does that help?
# 4  
Old 03-18-2011
Execute the count of what ?
the number of time the command4 has been found for that date ?
or the total number of entries in all record containing the command 4 for that date ?

Code:
# cat tst
03/17/2011
id number
command1
command2
command3
command4
data
data
data

03/18/2011
id number
command1
command2
command3
command4
data
data
data

03/18/2011
id number
command1
command2
command3
command4
data
data
data

Code:
# set -- $(echo "03/18/2011 command4")

Code:
# awk -v d="$1" -v p="$2" '$1~d{x=1}NF<1{x=0}$0~p&&x{s++}END{print s}' tst
2
#

Code:
# awk -v d="$1" -v p="$2" '$1~d{x=1}NF<1{x=0}$0~p&&x' tst
command4
command4


Last edited by ctsgnb; 03-18-2011 at 05:23 PM..
# 5  
Old 03-20-2011
Quote:
Originally Posted by ctsgnb
Execute the count of what ?
the number of time the command4 has been found for that date ?
or the total number of entries in all record containing the command 4 for that date ?
I want to count every instance of command 4 for the date specified.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Help on script to capture info on log file for a particular time frame

Hi I have a system running uname -a Linux cmovel-db01 2.6.32-38-server #83-Ubuntu SMP Wed Jan 4 11:26:59 UTC 2012 x86_64 GNU/Linux I would like to capture the contents of /var/log/syslog from 11:00AM to 11:30AM and sent to this info via email. I was thinking in set a cron entry at that... (2 Replies)
Discussion started by: fretagi
2 Replies

2. UNIX for Dummies Questions & Answers

Finding SSL Cert Info

How do I find out the SSL cert info on the local server? How do I know if an ssl cert is installed on local server? How it was issued to? Who was the issuer? What's the expiration date? Any other relevant information? (1 Reply)
Discussion started by: scj2012
1 Replies

3. Shell Programming and Scripting

How to select bulk of info from log file?

unix : sun shell : bash i need to select multiple rows with this format : <special format> 10 lines /<special format> from log file that have lots of info i thought of getting the number of the first line using grep -n "special format" file | cut -d: -f1 then pass it to shell... (2 Replies)
Discussion started by: scorpioneer
2 Replies

4. Linux

Finding IP info from access_log file

I found the /var/www/logs/access_log file (access log in order to find specific information about IP, And when users last logged in.) but in my fedora the access_log file is is in my /var/log/cups and it looks different from what it should be. Why is that? my goal is to get a list of IP... (4 Replies)
Discussion started by: bugenhagen_
4 Replies

5. Shell Programming and Scripting

Getting info from a huge log file

Hello everyone. I am having problem with parsing a data from the huge log file. the log file is an application log with around 5 Gb in size and it rotates every midnight. Now if the application encountered such issue, it sends an email with a specific info but without further details. So I... (13 Replies)
Discussion started by: cwiggler
13 Replies

6. UNIX for Dummies Questions & Answers

Need help with finding info on pcode-interpreters-virtual machines

I'm trying to research interpreters and I can't find much info on Pcode or how or why it is used. Thanks in advance!:wall: (2 Replies)
Discussion started by: theKbStockpiler
2 Replies

7. Shell Programming and Scripting

Log File - Getting Info about preceding Date of Pattern Found

Ok Suppose I have a log file like the below: 2010-07-15 00:00:01,410 DEBUG 2010-07-15 00:01:01,410 DEBUG 2010-07-15 00:01:02,410 DEBUG com.af ajfajfaf affafadfadfd dfa fdfadfdfadfadf fafafdfadfdafadfdaffdaffadf afdfdafdfdafafd error error failure afdfadfdfdfdf EBUDGG eafaferror failure... (6 Replies)
Discussion started by: SkySmart
6 Replies

8. Shell Programming and Scripting

Finding & Moving Oldest File by Parsing/Sorting Date Info in File Names

I'm trying to write a script that will look in an /exports folder for the oldest export file and move it to a /staging folder. "Oldest" in this case is actually determined by date information embedded in the file names themselves. Also, the script should only move a file from /exports to... (6 Replies)
Discussion started by: nikosey
6 Replies

9. UNIX for Dummies Questions & Answers

Finding file version info

Hi, Is there a standard command for retrieving the version of any given file (assuming the file has a version)? Thanks in advance Dave :) (1 Reply)
Discussion started by: davewg
1 Replies

10. UNIX for Dummies Questions & Answers

Finding system info

Can someone tell me the command to display the info about the CPU? I need the CPI id.. of my SUN box. Solaris 8. It's some totally un-intuitive command, and i can't recall it. tnx. (3 Replies)
Discussion started by: ireeneek
3 Replies
Login or Register to Ask a Question