![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| weird file list problem | jmmora | AIX | 8 | 08-08-2008 11:18 AM |
| Weird crontab problem | RobSand | SUN Solaris | 8 | 10-09-2007 05:12 PM |
| Weird problem with output from "date '+3600*%H+60*%M+%S' " | m223464 | Shell Programming and Scripting | 5 | 02-16-2006 12:22 PM |
| weird problem with removing files | rein | UNIX for Advanced & Expert Users | 2 | 08-15-2005 07:51 AM |
| Weird Problem??? | danhodges99 | UNIX for Dummies Questions & Answers | 2 | 04-11-2003 11:05 AM |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
I am trying to find the difference in days between 2 dates.
I have to extract the 1st date from a filename, which i did using the awk command. I have to compare this date to today's date and if the difference is greater than 30 days, do something, else do something else. This is what i wrote Code:
INVDATE=`echo "SHIP_606400_2008233202_20080206_070308083544.xml"|awk -F_ '{print $4}'`
echo $INVDATE
TODAY=`date +"%Y%m%d"`
echo $TODAY
(( diff=$TODAY-$INVDATE))
echo $diff
if [ $diff -gt 30 ]; then
#do a
else
#do b
fi
Code:
20080206 20080311 105 What am i doing wrong - I am pretty new to Shell programming and am learning through this site. Thanks in advance. |
| Bookmarks |
| Tags |
| linux, mtime, perl, perl regex, regex, ubuntu |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|