0

I am trying to find last day of the month. Date in DDMMYYYY format.

#!/bin/bash

start_date=01092018

end_date=$(date +%m%Y -d "$start_date +1 month")
echo $end_date

Expected Result :30092018

But it gives below error : Invalid character in date/time specification. Usage :date [-u] [+Field Descriptors]

1
  • 1
    Aix!date doesn't know GNU extensions. You could use Perl for such calculations. Example: github.com/lzsiga/pldate perl pldate set 20180901 add-month 1 printf %m%Y Commented Dec 23, 2019 at 13:42

1 Answer 1

0

AIX date do not support -d. So you can't use constructions like date -d. For reference you can check AIX date man page

Nut you can try something in perl:

perl -MPOSIX -le '@x=localtime; if($x[4]!=0) {$x[4]++} else {$x[4]=11;$x[5]++};print strftime ("%Y-%m-%d", @x)'
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.