Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Comparing Output Date to Current System Date Post 302582527 by methyl on Friday 16th of December 2011 09:07:38 AM
Old 12-16-2011
Another idea. Bear in mind that because your match includes HH:MM your file needs to be totally up-to-date to get a match. I've assumed that the original log file entries came from the "date" command with no parameters.

Code:
today="`date|cut -c1-16`"
grep "${today}" abc161.txt 2>&1 >/dev/null ; reply=$?
if [ $reply -eq 0 ]
then
        echo "File contains: ${today}"
fi

 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

I want to get day from the current system date

Hi, I want to check what day is today (like mon,Tue,wed) When i checked the syntax, i dont see there is a format specifier for getting the day. Let me know how to get the same. I am very new to unix and so I am asking some basic questions. cheers, gops (2 Replies)
Discussion started by: gopskrish
2 Replies

2. Shell Programming and Scripting

Perl: Extracting date from file name and comparing with current date

I need to extract the date part from the file name (20080221 in this ex) and compare it with the current date and delete it, if it is a past date. $file = exp_ABCD4_T-2584780_upto_20080221.dmp.Z really appreciate any help. thanks mkneni (4 Replies)
Discussion started by: MKNENI
4 Replies

3. UNIX for Dummies Questions & Answers

get current system date

How do I create a shell script that would get the current system date in format of yyyymmdd and use that result to concatenate it to a filename that it would look like this: sample20051024.dat example -------- current system date: 24-Oct-2005 filename: sample.dat when the shell script... (5 Replies)
Discussion started by: wtolentino
5 Replies

4. Shell Programming and Scripting

how to get what date was 28 days ago of the current system date IN UNIX

Hi, Anybody knows how to get what date was 28 days ago of the current system date through UNIX script. Ex : - If today is 28th Mar 2010 then I have to delete the files which arrived on 1st Mar 2010, (15 Replies)
Discussion started by: kandi.reddy
15 Replies

5. Shell Programming and Scripting

Comparing current date

Hi, I have start date and end date in the following format. I need to check the current date is greater than the start date and less than the end date. if i use the command date --date "Tue 6:00 AM", it takes next Tues day not the current week's Tues day. Is there a way to get the current Tues... (9 Replies)
Discussion started by: bharathappriyan
9 Replies

6. 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

7. UNIX for Dummies Questions & Answers

Comparing two files with datestamp to current date

Hi, I am new to unix and I am stuck on how to compare two .zip file with date stamp in my directory. I need to compare out of the two file which is oldest to current date and unzip it after that done continue to unzip the second zip file. Thanks for your help. (5 Replies)
Discussion started by: lilvi3tboix1
5 Replies

8. Shell Programming and Scripting

Comparing the dates with the current date in perl scripting

Hi i have a file containg dates likebelow 4/30/2013 3/31/2013 4/30/2013 4/16/2013 4/30/2013 4/30/2013 5/30/2013 5/30/2013 4/30/2013 5/30/2013 5/30/2013 3/31/2013 now i want to compare the above dates with current date and i want to display the difference . (10 Replies)
Discussion started by: siva kumar
10 Replies

9. UNIX for Beginners Questions & Answers

Compare date in .txt with system date and remove if it's lesser than system date

Can someone help me with the code wherein there is a file f1.txt with different column and 34 column have expiry date and I need to get that and compare with system date and if expiry date is <system date remove those rows and other rows should be moved to new file f2.txt . I don't want to delete... (2 Replies)
Discussion started by: Stuti
2 Replies

10. Answers to Frequently Asked Questions

Compare date in .txt with system date and remove if it's lesser than system date

I m working on shell scripting and I m stuck where in my .txt file there is column as expiry date and I need to compare that date with system date and need to remove all the rows where expiry date is less than system date and create a new .txt with update. (1 Reply)
Discussion started by: Stuti
1 Replies
CONVDATE(1)						    InterNetNews Documentation						       CONVDATE(1)

NAME
convdate - Convert to/from RFC 5322 dates and seconds since epoch SYNOPSIS
convdate [-dhl] [-c | -n | -s] [date ...] DESCRIPTION
convdate translates the date/time strings given on the command line, outputting the results one to a line. The input can either be a date in RFC 5322 format (accepting the variations on that format that innd(8) is willing to accept), or the number of seconds since epoch (if -c is given). The output is either ctime(3) results, the number of seconds since epoch, or a Usenet Date: header, depending on the options given. If date is not given, convdate outputs the current date. OPTIONS
-c Each argument is taken to be the number of seconds since epoch (a time_t) rather than a date. -d Output a valid Usenet Date: header instead of the results of ctime(3) for each date given on the command line. This is useful for testing the algorithm used to generate Date: headers for local posts. Normally, the date will be in UTC, but see the -l option. -h Print usage information and exit. -l Only makes sense in combination with -d. If given, Date: headers generated will use the local time zone instead of UTC. -n Rather than outputting the results of ctime(3) or a Date: header, output each date given as the number of seconds since epoch (a time_t). This option doesn't make sense in combination with -d. -s Pass each given date to the RFC 5322 date parser and print the results of ctime(3) (or a Date: header if -d is given). This is the default behavior. EXAMPLES
Most of these examples are taken, with modifications from the original man page dating from 1991 and were run in the EST/EDT time zone. % convdate '10 Feb 1991 10:00:00 -0500' Sun Feb 10 10:00:00 1991 % convdate '13 Dec 91 12:00 EST' '04 May 1990 0:0:0' Fri Dec 13 12:00:00 1991 Fri May 4 00:00:00 1990 % convdate -n '10 feb 1991 10:00' '4 May 90 12:00' 666198000 641880000 % convdate -c 666198000 Sun Feb 10 10:00:00 1991 ctime(3) results are in the local time zone. Compare to: % convdate -dc 666198000 Sun, 10 Feb 1991 15:00:00 +0000 (UTC) % env TZ=PST8PDT convdate -dlc 666198000 Sun, 10 Feb 1991 07:00:00 -0800 (PST) % env TZ=EST5EDT convdate -dlc 666198000 Sun, 10 Feb 1991 10:00:00 -0500 (EST) The system library functions generally use the environment variable TZ to determine (or at least override) the local time zone. HISTORY
Written by Rich $alz <rsalz@uunet.uu.net>, rewritten and updated by Russ Allbery <rra@stanford.edu> for the -d and -l flags. $Id: convdate.pod 8894 2010-01-17 13:04:04Z iulius $ SEE ALSO
active.times(5). INN 2.5.2 2010-02-08 CONVDATE(1)
All times are GMT -4. The time now is 09:48 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy