AIX This forum is for the discussion of IBM AIX.
eserver and other IBM related questions are also on topic. |
| Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
 |
GNU/Linux Basic Guide
This 255-page guide will provide you with the keys to understand the philosophy of free software, teach you how to use and handle it, and give you the tools required to move easily in the world of GNU/Linux. Many users and administrators will be taking their first steps with this GNU/Linux Basic guide and it will show you how to approach and solve the problems you encounter.
Click Here to receive this Complete Guide absolutely free. |
|
 |
01-24-2013, 03:56 AM
|
#1
|
|
LQ Newbie
Registered: Jan 2013
Posts: 10
Rep: 
|
shell script for date
hi
how to do a shell script in aix to display 15 day before the current date.
Last edited by rajachan; 01-24-2013 at 04:15 AM.
|
|
|
|
01-24-2013, 05:17 AM
|
#2
|
|
Member
Registered: Oct 2012
Distribution: OpenSuSE,RHEL,OpenBSD
Posts: 500
Rep: 
|
perl -e 'print scalar localtime (time - (15 * 86400))'
|
|
|
2 members found this post helpful.
|
01-26-2013, 12:44 AM
|
#3
|
|
Senior Member
Registered: Jul 2012
Location: Grenoble, Fr.
Distribution: Sun Solaris, RHEL, Ubuntu, Debian 6.0
Posts: 1,635
|
Not much sure about AIX, but can you try like bash style:
Code:
PREVDATE=$(date --date="15 day ago")
echo $PREVDATE
|
|
|
|
01-27-2013, 02:48 PM
|
#4
|
|
Bash Guru
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Debian sid + kde 3.5 & 4.4
Posts: 6,589
|
AIX's version of date doesn't have -d, so that won't work.
A quick google turned up this date script. I don't know how well it works:
http://www.williamrobertson.pwp.blue...shift_date.txt
|
|
|
|
01-28-2013, 01:30 AM
|
#5
|
|
LQ Newbie
Registered: Jan 2013
Posts: 10
Original Poster
Rep: 
|
thanks linosaurusroot
your command is working
i am getting the result in following format...
sun jan 13 hh:mm::sec 2013
is it possible to display the date in below format..
13-jan-13
|
|
|
|
01-28-2013, 04:13 AM
|
#6
|
|
Member
Registered: Oct 2012
Distribution: OpenSuSE,RHEL,OpenBSD
Posts: 500
Rep: 
|
"perldoc localtime" shows the breakdown.
|
|
|
|
01-28-2013, 09:03 AM
|
#7
|
|
Senior Member
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 1,047
|
you might want to install GNU-date, perhaps by name gdate so you could use this way:
Code:
gdate -d'15 days ago' +%d-%b-%y
|
|
|
|
01-31-2013, 01:15 PM
|
#8
|
|
Bash Guru
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Debian sid + kde 3.5 & 4.4
Posts: 6,589
|
You could also use nawk or gawk if you have them (posix awk/ mawk don't have time functions).
Code:
nawk 'BEGIN{ print strftime( "%d-%b-%y" , systime() - 15 * 86400 ) }'
|
|
|
|
| Thread Tools |
Search this Thread |
|
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -5. The time now is 06:40 PM.
|
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|