07-13-2009
Quote:
Thanks for you answer fpmurphy.
You code is working but i got little problem.
The printf command is not working for the T. So i have modified your command littel bit. See the command i have modified.
if (( $(printf "%s" "$toed") < $(printf "%s" "$shud") ))
toed and shud are the two variables which contains only date in the format 07/12/2009 and its working for date.
now i am storing two time values in the format 22:02:53. now i need to compare the times also. how do i full fill it.
Your "little bit" modification is invalid. You end up trying to numerically compare two strings. My example only works with Korn Shell 93 and requires the use of the %(%s)T syntax.
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
HI,
I am able to find days difference using FIND command. However it is comparing between today and the last time it was modified.
I now need to find the difference between a date specified by myself and the last time the file was modified. Is there a command which I can use or I have to... (1 Reply)
Discussion started by: scmay
1 Replies
2. Shell Programming and Scripting
hi ,
I have two variables both containg dates,
x= `date`
and
y= `date'
their format being -> Fri Nov 12 22:59:50 MST 2004
how do I compare which one is greater.
->Can dates be converted into integer and then compared?
( one lengthy way would be to compare the words one by... (7 Replies)
Discussion started by: k_oops9
7 Replies
3. Programming
hi
is there a c function in linux for comparing dates.
thanx in advance.
svh (2 Replies)
Discussion started by: svh
2 Replies
4. Shell Programming and Scripting
Hi All.
Can someone please give me an example of how I'd do a comparison to find out if the last modified date of a file is newer than yesterday (i.e. today - 1 day)?
Example:
if ; then
echo "Do something..."
fi
Any ideas or examples?
Thanks. (1 Reply)
Discussion started by: dmilks
1 Replies
5. Shell Programming and Scripting
Hi,
Can some one guide me how to compare two dates in unix.
TIA
Gupta (5 Replies)
Discussion started by: guptan
5 Replies
6. Shell Programming and Scripting
Hi guys
I have a a variable called check_ts which holds a date value. this date value keeps refreshing every 15 minutes.
I am going to start a cron job 5 minutes after the refresh. I have to check if the current date > 20 min of check_ts. how do i do that.
thanks
ragha (17 Replies)
Discussion started by: ragha81
17 Replies
7. Shell Programming and Scripting
Hi,
I want to compare today's date(DDMMYYYY) with yesterday(DDMMYYYY) from system date,if (today month = yesterday month) then execute alter query else do nothing.One more condition is change of year also i.e today is Jan1 2012 and yesterday is Dec 31 2011.
The above rek i want in Shell... (4 Replies)
Discussion started by: kumarmsk1331
4 Replies
8. Shell Programming and Scripting
Hi
I'm trying to compare the current date (dd-Mmm-yyyy) against a variable that is an extracted date from an sql script. Below is the code:
datenow=`date '+%d-%h-%Y'`
#datenow is the current date in the format dd-Mmm-yyyy
sqlplus $dbuserid/$dbpassword @ $SCRIPT_PATH/business-date.sql >... (3 Replies)
Discussion started by: joyAV
3 Replies
9. UNIX for Dummies Questions & Answers
Hi,
can we do date comparisons in unix? like if i give the two dates find which date is old one and which is new one and difference between the two dates in terms of hours,minutes,days and months. (1 Reply)
Discussion started by: vmachava
1 Replies
10. Shell Programming and Scripting
Hi
I am failing to write a script which compares a list of dates in a file with today's date.
OS: Solaris 10
I have a file which has server names & dates, i need to compare the date in this file with today's date, if it is less than today it should print the server name.
code i tried is ... (3 Replies)
Discussion started by: nanz143
3 Replies
LEARN ABOUT REDHAT
printf
PRINTF(1) FSF PRINTF(1)
NAME
printf - format and print data
SYNOPSIS
printf FORMAT [ARGUMENT]...
printf OPTION
DESCRIPTION
NOTE: your shell may have its own version of printf which will supercede the version described here. Please refer to your shell's documen-
tation for details about the options it supports.
Print ARGUMENT(s) according to FORMAT.
--help display this help and exit
--version
output version information and exit
FORMAT controls the output as in C printf. Interpreted sequences are:
" double quote
NNN character with octal value NNN (0 to 3 digits)
\ backslash
a alert (BEL)
backspace
c produce no further output
f form feed
new line
carriage return
horizontal tab
v vertical tab
xNNN byte with hexadecimal value NNN (1 to 3 digits)
uNNNN character with hexadecimal value NNNN (4 digits)
UNNNNNNNN
character with hexadecimal value NNNNNNNN (8 digits)
%% a single %
%b ARGUMENT as a string with `' escapes interpreted
and all C format specifications ending with one of diouxXfeEgGcs, with ARGUMENTs converted to proper type first. Variable widths are han-
dled.
AUTHOR
Written by David MacKenzie.
REPORTING BUGS
Report bugs to <bug-coreutils@gnu.org>.
COPYRIGHT
Copyright (C) 2002 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICU-
LAR PURPOSE.
SEE ALSO
The full documentation for printf is maintained as a Texinfo manual. If the info and printf programs are properly installed at your site,
the command
info printf
should give you access to the complete manual.
GNU coreutils 4.5.3 February 2003 PRINTF(1)