getting string after date in log


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting getting string after date in log
# 8  
Old 02-29-2012
The following code should display all the lines relating to a date that match $TODAY or $YESTERDAY (also all the subsequent lines relating to those matching dates (not only the 5 first))

Code:
awk -v T="$TODAY" -v Y="$YESTERDAY" '/^..\/..\/../{x=$1}x==T||x==Y' yourfile.log


Last edited by ctsgnb; 02-29-2012 at 04:19 AM..
This User Gave Thanks to ctsgnb For This Post:
# 9  
Old 02-29-2012
The code is perfect now

Can you guide me regarding how to get the next few lines attached to this date string (suppose 4 lines)
# 10  
Old 02-29-2012
Doesn't that code already get them ?

(I meanwhile fixed my code replacing $1==T||$1==Y with x==T||x==Y )

Last edited by ctsgnb; 02-29-2012 at 04:32 AM..
This User Gave Thanks to ctsgnb For This Post:
# 11  
Old 02-29-2012
Thx a lot!
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Converting String Date into UNIX Date

Hi, I have a string date to my unix script(sun solaris). I wanted to convert it into unix date so that I can use it in a conditional statement. Please see below: MyTest.sh -s 2018-05-09 suppdt=$1 # string date passed via arguement as 2018-04-09 curryr=`date '+%Y'` nextyr=`expr... (2 Replies)
Discussion started by: Saanvi1
2 Replies

2. UNIX for Dummies Questions & Answers

Copy log based on from-date and to-date

Hi all, i go a customer support requirement where i need to scan several files based on from/to date like 1-oct to 2-oct please help... (3 Replies)
Discussion started by: AbhiJ
3 Replies

3. UNIX for Dummies Questions & Answers

I need a Script to read Log string and check date at the same time

I need to check 1 log file, which is logging: 2014-08-18T09:10:39+02:00 user: XXXXX START FEATURE 2014-08-18T09:10:39+02:00 user: XXXXX FINISH FEATURE I first need to check that the START FEATURE starts and finish on the same time/date for the same user, which is different each time START... (2 Replies)
Discussion started by: TheBest43
2 Replies

4. UNIX for Dummies Questions & Answers

Search for a specific String in a log file for a specific date range

Hi, I have log file which rolls out every second which is as this. HttpGenRequest - -<!--OXi dbPublish--> <created="2014-03-24 23:45:37" lastMsgId="" requestTime="0.0333"> <response request="getOutcomeDetails" code="114" message="Request found no matching data" debug="" provider="undefined"/>... (3 Replies)
Discussion started by: karthikprakash
3 Replies

5. Shell Programming and Scripting

Compare Date with String in date format

Hi, I am new to this forum, searched, but for some reason did not find much help, so a new thread. I am trying to compare date with a string which is in date format , but for some reason, system does not give me the right result. Date is coming in a file and i am comparing the same with... (2 Replies)
Discussion started by: mkstool
2 Replies

6. Shell Programming and Scripting

Delete log files content older than 30 days and append the lastest date log file date

To delete log files content older than 30 days and append the lastest date log file date in the respective logs I want to write a shell script that deletes all log files content older than 30 days and append the lastest log file date in the respective logs This is my script cd... (2 Replies)
Discussion started by: sreekumarhari
2 Replies

7. Homework & Coursework Questions

Get Julian date from date string

Hi, im new for UNIX. i have a problem in date function. please help me to find a solution. batchdate="29/10/2010" nextdate="01/11/2010" i want compare this two date. if my batch date greater than nextdate should prompt error message. how can i do that? as i know its better and safer if i... (2 Replies)
Discussion started by: ananth4mu
2 Replies

8. Shell Programming and Scripting

Need to get next valid date from date string

Hi, I am passing date string of format 'YYYYMMDD' to a ksh script. Will I be able to get next valid date from the passed in string. Example I pass '20100228' to the shell script, Is there a reverse date command to get '20100301' .i.e to convert '20100228' to date and get next date.... (5 Replies)
Discussion started by: bittoo
5 Replies

9. Homework & Coursework Questions

Date comparison with 'string date having slashes and time zone' in Bash only

1. The problem statement, all variables and given/known data: I have standard web server log file. It contains different columns (like IP address, request result code, request type etc) including a date column with the format . I have developed a log analysis command line utility that displays... (1 Reply)
Discussion started by: TariqYousaf
1 Replies
Login or Register to Ask a Question