Fetch contents of file greater than date

Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Fetch contents of file greater than date
# 1  
Old 07-25-2011
Fetch contents of file greater than date

I have an input file which looks like something mentioned below:
25/07/2011 05:06:59 [10173]: test
25/07/2011 05:06:59 [10171]: test1
25/07/2011 05:08:09 [10173]: test2

I need to write a script which will take date in the format "25/07/2011 05:07:01" as input and compare it with the contents of the above mentioned file. Any line starting with the date greater than the input variable will be dumped in the output file.

So the expected output in this case is:
25/07/2011 05:08:09 [10173]: test2

# 2  
Old 07-25-2011
What have you tried so far? ...

$> read I; I=$(echo $I| awk -F"[/ :]" 'NF==6{print $3$2$1$4$5$6}'); awk -F"[/ :]" -v i=$I 'NF>1 {a=$3$2$1$4$5$6; if(i>a){print}}' infile
25/07/2011 05:07:01
25/07/2011 05:06:59 [10173]: test
25/07/2011 05:06:59 [10171]: test1

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Linux

Filter log file contents between date

Hi, Could you please provide me command to filter contents between date in a log file? Say for example, in a log file I want to capture contents between date May 01 from 5am to 9 am. OS -- Linux Regards, Maddy (1 Reply)
Discussion started by: Maddy123
1 Replies

2. Shell Programming and Scripting

Not able to fetch previous month first date and last date

I am not able to fetch first date and last date previous month date -d -1month +%Y-%m-%d date -d -1month +%Y-%m-%d I need two format dd-mm-yyy previous month 01-03-2016 previous month 31-03-2016 and also only date 1 to 31 Aprriciate your replay (4 Replies)
Discussion started by: jagu
4 Replies

3. UNIX for Advanced & Expert Users

Get the date greater than defined date

file.txt 2013-01-01 2013-01-02 2013-01-03 2013-01-04 I need some method to get only date which are greater than 2013-01-03 in a seperate file 2013-01-03 2013-01-04 I have tried cat file.txt | awk -F. '$2 > '2013-01-03' {print $0}' >> a2.txt (9 Replies)
Discussion started by: ATWC
9 Replies

4. Shell Programming and Scripting

Folder contents getting appended as strings while redirecting file contents to a variable

Hi one of the output of the command is as below # sed -n "/CCM-ResourceHealthCheck:/,/---------/{/CCM-ResourceHealthCheck:/d;/---------/d;p;}" Automation.OutputZ$zoneCounter | sed 's/$/<br>/' Resource List : <br> *************************** 1. row ***************************<br> ... (2 Replies)
Discussion started by: vivek d r
2 Replies

5. Shell Programming and Scripting

Concatenate many files which contents the same date as part of name file

Gents, I have lot of files in a folder where each file name includes the date of generation, then I would like to merge all the files for each date in a complete file. list of files in forder. dsd01_121104.txt dsd01_121105.txt dsd01_121106.txt dsd03_121104.txt dsd03_121105.txt... (7 Replies)
Discussion started by: jiam912
7 Replies

6. Shell Programming and Scripting

Find files greater than a particular date in filename.

I need a unix command which will find all the files greater that a particular date in the file name. say for example I have files like(filenaming cov : filename.YYDDMMSSSS.txt) abc.201206015423.txt abc.201207013456.txt abc.201202011234.txt abc.201201024321.txt efg.201202011234.txt... (11 Replies)
Discussion started by: lijjumathew
11 Replies

7. Shell Programming and Scripting

Fetch date of 7 years back from current date in Perl

$beginDate = substr(DateCalc("today", "-7Days"),0,8); This fetches the date 7 days back Can I fetch the date before 7 years from todays date in Perl using same syntax Use code tags, see PM. (3 Replies)
Discussion started by: parthmittal2007
3 Replies

8. Shell Programming and Scripting

Replace partial contents of file with contents read from other file

Hi, I am facing issue while reading data from a file in UNIX. my requirement is to compare two files and for the text pattern matching in the 1st file, replace the contents in second file by the contents of first file from start to the end and write the contents to thrid file. i am able to... (2 Replies)
Discussion started by: seeki
2 Replies

9. UNIX for Dummies Questions & Answers

List of Files which are Greater then a specific date

A newbie question... I need to get a list of the Files and folders which are greater then a specific date. I want write the output to a Text file. What I know ls -lrt gives me list of all the files ordered by date. Also ls > fileName will write the results to a text file. Please help (6 Replies)
Discussion started by: rkaif
6 Replies

10. UNIX for Dummies Questions & Answers

Delete a row from a file if one column containing a date is greater than the current system date

Hello gurus, I am hoping someone can help me with the required code/script to make this work. I have the following file with records starting at line 4: NETW~US60~000000000013220694~002~~IT~USD~2.24~20110201~99991231~01~01~20101104~... (4 Replies)
Discussion started by: chumsky
4 Replies
Login or Register to Ask a Question