Date Incremental in AIX

Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Date Incremental in AIX
# 1  
Old 11-12-2013
Date Incremental in AIX

I am trying to find an option in unix to increment for date filed.
I tried in the unix forums. unable to find the direct command to increment the value.

a= 01/Apr/13

while [ $a -lt 5 ]
   echo $a
   a=`expr $a + 1`

a= 01/Apr/13


Any help greatly appreciated.

Last edited by Scott; 11-12-2013 at 07:21 PM.. Reason: Code tags for data too, please...
# 2  
Old 11-12-2013


n=$(echo "${a:0:2}-1" | bc) 

# OR n=0 also will work

while [ $n -lt 5 ]; do
     date -d "$a + $n day" +%d/%b/%y

$ bash

Last edited by Akshay Hegde; 11-12-2013 at 03:52 PM.. Reason: color
# 3  
Old 11-12-2013
Thanks for the quick response but it is giving as an error
a=${a//\//-}: bad substitution

Last edited by Scott; 11-12-2013 at 07:19 PM.. Reason: Code tags
# 4  
Old 11-12-2013
Don't know about your bash

replace a=${a//\//-} by a=$(echo "$a" | sed 's/\//-/g') and then try let me know about result
# 5  
Old 11-12-2013
now that statement not giving an error but giving different error.
"${a:0:2}-1": bad substitution

Last edited by Scott; 11-12-2013 at 07:21 PM.. Reason: Code tags
# 6  
Old 11-12-2013
which bash run this
bash --version | head -1

if you have ksh93 try with ksh
# 7  
Old 11-12-2013
GNU bash, version 4.1.9(1)
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. AIX

How do you keep your AIX skills up to date?

I am very curious to find out how AIX admins keep up to date and refreshed with all of the options and features of AIX without having access to a test environment? Usually going on a course requires practice otherwise the knowledge gained can get lost very quickly. How do you practice for the... (5 Replies)
Discussion started by: Colin_Fearnley
5 Replies

2. UNIX for Dummies Questions & Answers

Date format change in AIX

Hi I have a date format in a variable as Apr 7 03:35:59 EDT 2016. how do i change it to 04/07/2016 03:35:59 EDT format (5 Replies)
Discussion started by: sushma123
5 Replies

3. Shell Programming and Scripting

Date formatting in AIX

Can you help in formating the date command in aix to get the following format Oct 11 21:52 Fri Oct 11 21:52:01 PDT 2013 Required output: Oct 11 21:52 Fri Oct 11 21:52:01 PDT 2013 (1 Reply)
Discussion started by: chandu123
1 Replies

4. UNIX for Advanced & Expert Users

Subtract days to a date in AIX 5.3

good afternoon, can someone help me, I need to make a script where n subtract days to a date. I am using AIX 5.3. Greetings. (4 Replies)
Discussion started by: systemoper
4 Replies

5. Shell Programming and Scripting

How to display yesterday Date in AIX

Hi, I need help to display the yesterday date in format mentioned below: 2012-06-26-PMI tried this but it displays current date: `date +%Y-%m-%d-%p` (9 Replies)
Discussion started by: aroragaurav.84
9 Replies

6. AIX

Get Next month in AIX from curent date in unix AIX

How could we derive teh Next month in MON-RR format from current date ie sysdate in UNI AIX sheel script.I coould get a command but i supports only inLinux susse andnotin AIX. I need for Unix AIX.Pls Help. Regards Shiv (2 Replies)
Discussion started by: SHIV75
2 Replies

7. Shell Programming and Scripting

current date - one month in AIX

Hi, i unable to get the last month date in AIX. current date - one month Based on the forums tried but did not find the relevent information. Any help grealy appriciated. Thanks Suri. (3 Replies)
Discussion started by: onesuri
3 Replies

8. Shell Programming and Scripting

To Get the day of given date in aix

Hi, Can any one help to find out the day for the given date in AIX. If we giving date as "YYYYMMDD" it should display its day. eg:if the input is "20120103", expected output is "tuesday" :wall: Pls help (7 Replies)
Discussion started by: novaothers
7 Replies

9. AIX

How to get the date yesterday in AIX sh

Hi, In AIX sh, how to return the date of yesterday in format of %Y%m%d, YYYYMMDD. i.e. if today is 20080704, I want it return 20080703. Can anyone help? Thanks! Victor Cheung (4 Replies)
Discussion started by: victorcheung
4 Replies

10. AIX

date command in AIX

hi, i have a simple question in linux: date '+%s' -r filename--------> gives the file age in seconds i want the option to be used with date command in AIX ?? (1 Reply)
Discussion started by: ali560045
1 Replies
Login or Register to Ask a Question