If I do a date + "%b%Y" I get Mar2004. How do I then get unix to tell me that the previous month and year is Feb2004? The logic will also have to work for Jan2005 and Dec2004. Thanks..
1) dont use the Alphabetical version of the month.
1a) use a case statement to translate the numercial month to a Alphabetical version if that is your requirement.
2) use a case statement.
by useing the numerical number vs. alphabet you can do simple math to get the previous month.
It depends on what system you're on. For example, GNU date (installed on Linux boxes) will allow this:
If it's worth it, and possible, (in some cases it may be both), you can head over to GNU.org and download GNU "sh-utils" package.
If you have an RDBMS like Informix, Oracle or MySql installed you might consider using that to perform the date calculations for you.
In a script:
1. Create a 'temporary' table with a date type column
2. Populate the date column with an insert statement.
3. Perform the calculation with a select statement. e.g.
select (mydate -1)
from tt_calc
4. Drop the table once you have finished with it.
All of the above actions can certainly be scripted using Shell Script and Informix. The return value of step 3 can be captured into a shell variable. The format returned will depend on your RDBMS and how it is configured.
Hi all,
I need to increment date at run time.
Example:
I need to write a shell script with two parameters.
1. country code like (US,UK, IND.....)
2. Date range from_date to to_date (20070101 to 20070331)
I need to run shell script like this
country_info.sh US 20070101 20070331
... (3 Replies)
Dear friends,
I receive the following files into a FTP location on a daily basis
-rw-r----- 1 guest ftp1 5021 Aug 19 09:03 CHECK_TEST_Extracts_20080818210000.zip
-rw-r----- 1 guest ftp1 2437 Aug 20 05:15 CHECK_TEST_Extracts_20080819210000.zip
-rw-r----- 1 guest ... (2 Replies)