script for get lines with specific date


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting script for get lines with specific date
# 1  
Old 12-20-2011
script for get lines with specific date

I'm a newbie in AIX, i want to make a script for grep any lines with date bellow 20
Code:
PRINT0089-88615        data1            3072   Mon Dec 19 17:53:49 WITA 2011
PRINT0089-88616        data1            4096   Mon Dec 19 17:53:49 WITA 2011
PRINT0089-88618        data1            5120   Mon Dec 19 17:54:19 WITA 2011
PRINT0272-88668        data1            3072   Mon Dec 19 20:36:42 WITA 2011
PRINT0331-88700        data1            2048   Tue Dec 20 01:03:10 WITA 2011
PRINT0331-88701        data1           77824   Tue Dec 20 01:03:11 WITA 2011
PRINT0152-88713        data1          654336   Tue Dec 20 01:11:53 WITA 2011
PRINT0089-88794        data1            3072   Tue Dec 20 07:20:05 WITA 2011
PRINT0089-88831        data1            3072   Tue Dec 20 07:48:36 WITA 2011
PRINT0089-88890        data1            3072   Tue Dec 20 08:03:07 WITA 2011
PRINT0089-88900        data1            3072   Tue Dec 20 08:07:38 WITA 2011
PRINT0331-90127        data1          100352   Wed Dec 21 01:03:14 WITA 2011
PRINT0089-90130        data1            3072   Wed Dec 21 01:08:48 WITA 2011
PRINT0089-90207        data1            3072   Wed Dec 21 07:46:07 WITA 2011
PRINT0089-90238        data1            3072   Wed Dec 21 07:56:57 WITA 2011
PRINT0089-90265        data1            3072   Wed Dec 21 08:03:58 WITA 2011

please help me!
# 2  
Old 12-20-2011
For anything from 1900-1999 try:

Code:
grep "WITA 19[0-9][0-9]$" logfile

# 3  
Old 12-20-2011
"Below 20" is ambiguous, currently the log file has only data for december, so the below code will do.
Code:
awk '$6<=20' logfile

But is that all you want?

--ahamed
# 4  
Old 12-20-2011
Quote:
Originally Posted by Chubler_XL
For anything from 1900-1999 try:

Code:
grep "WITA 19[0-9][0-9]$" logfile

I write the code
Code:
file=/print/printqeueu
file1=/print/printqeueu1
awk '$6 < 20 {print}' $file > $file1

but i must manual edit on script every change of date, for example 20.
how to get the date 3 days before today ?
# 5  
Old 12-20-2011
Code:
awk '$6<=(date-diff)' date=$(date +%d) diff=3 logfile

--ahamed
This User Gave Thanks to ahamed101 For This Post:
# 6  
Old 12-20-2011
As ahamed101 says currently your fine, but what happens on the 1st and 2nd (especially in Jan)?

Awk probably needs to be smarter and deal with a passed date.
# 7  
Old 12-20-2011
Chubler XL
For this time, my problem has been solved. But i don't know if in 1st or 2nd Jan. I should find out, i can not test the script because the server is for production.
Thank's for your comment...
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Date: invalid date trying to set Linux date in specific format

i try to set linux date & time in specific format but it keep giving me error Example : date "+%d-%m-%C%y %H:%M:%S" -d "19-01-2017 00:05:01" or date +"%d-%m-%C%y %H:%M:%S" -d "19-01-2017 00:05:01" keep giving me this error : date: invalid date ‘19-01-2017 00:05:01' Please use CODE tags... (7 Replies)
Discussion started by: umen
7 Replies

2. Shell Programming and Scripting

How can I apply 'date' command to specific columns, in a BASH script?

Hi everyone, I have a situation in which I have multiple (3 at last count) date columns in a CSV file (, delim), which need to be changed from: January 1 2017 (note, no comma after day) to: YYYY-MM-DD So far, I am able to convert a date using: date --date="January 12, 1990" +%Y-%m-%d ... (7 Replies)
Discussion started by: richardsantink
7 Replies

3. Shell Programming and Scripting

Removing specific lines from script files.

Hello, Activity to perform: 1. Find all of the "*.tmp" files in a given user directory 2. Determine which ones have "find" in them. 3. Replace the "find sequence" of commands with a "list set" of commands. Example: Original file: -------------- define lastn1 = "A" define... (7 Replies)
Discussion started by: manishdivs
7 Replies

4. Shell Programming and Scripting

Grep all lines for a specific date in log-files

I need to grep all lines for "yesterday" in /var/log/messages. Dates are in the format "YYYY-MM-DD". (5 Replies)
Discussion started by: Padmanabhan
5 Replies

5. Shell Programming and Scripting

script for get lines with specific time.

i want to make a script for grep any lines with key word and every time (5 min) Ex. Log in Server. . . . 03-01-2012 03:07:54,924 - INFO MessageUtil - Return | Status=0 | TxID=12010300000548755292 | Message=Success 03-01-2012 03:09:13,789 - INFO MessageUtil - Return | Status=0 |... (6 Replies)
Discussion started by: ooilinlove
6 Replies

6. Shell Programming and Scripting

Grep only specific lines ordered by column/date

Hi everybody, I'd like to think I've been through the search tool not only on this site, but also on google too, but I haven't been able to find what I was looking for. If I might've missed something on this forum, please slap me in the face with a link that you consider useful for my query :D ... (4 Replies)
Discussion started by: dilibau
4 Replies

7. Shell Programming and Scripting

shell script that will run for a specific date

Hi, I have these changes needed to modify a shell script that will run on a specific date of a month, below pseudocode, appreciate any answers..thanks.. if date of the month is 26th then ..event 1 fi if date of the month is 26th and month are MAR,JUN,SEP,DEC then ..event2 ... (7 Replies)
Discussion started by: sonja
7 Replies

8. Shell Programming and Scripting

Delete lines prior to a specific date in a log file.

Hi all. I have a database log file in which log data get appended to it daily. I want to do a automatic maintainence of this log by going through the log and deleting lines belonging to a certain date. How should i do it? Please help. Thanks. Example. To delete all lines prior to Jun... (4 Replies)
Discussion started by: ahSher
4 Replies

9. UNIX for Dummies Questions & Answers

command for selecting specific lines from a script

I need help on following script: I need to print the lines which are in bold letters in separate file as record string("|") emp_name; string("|") emp_id; decimal("|") emp_salary; string("|") emp_status; string("\n") emp_proj; end (1 Reply)
Discussion started by: gardasgangadhar
1 Replies

10. Shell Programming and Scripting

Shell Script to read specific lines in a file

I have a file with contents as follows Record 1: Rejected - Error on table "DWO"."P2G_CUST_EVENTS". ORA-00001: unique constraint (DWO.CUST_EVENTS_PK) violated Record 5: Rejected - Error on table "DWO"."P2G_CUST_EVENTS". ORA-00001: unique constraint (DWO.CUST_EVENTS_PK) violated Record 6:... (5 Replies)
Discussion started by: varshanswamy
5 Replies
Login or Register to Ask a Question