1828274 Members
3423 Online
109975 Solutions
New Discussion

Re: date manipulation

 
SOLVED
Go to solution
Andrej Vavro
Frequent Advisor

date manipulation

Hi,

how can I find last month name in bash script? Best would be in %b format.

Regards,
Andrej
6 REPLIES 6
Claudio Cilloni
Honored Contributor

Re: date manipulation

maybe I didn't understand you're question (my english isn't so good :-), but could you explain 'last month name'?

the date command can print dates in any way you like. man page helps a lot

C
Jarle Bjorgeengen
Trusted Contributor

Re: date manipulation

"Last month"="current month"-1

Rgds Jarle
Andrej Vavro
Frequent Advisor

Re: date manipulation

Colud you please provide more details about syntax in bash?

lastmonth = current - 1

I need just syntax. +1, -30 doesn't work in echo. I need just syntax.

Thanks
Andrej
Claudio Cilloni
Honored Contributor
Solution

Re: date manipulation

this seems to work:

$ date date --date="last month" +"%b"

hth
Claudio
Claudio Cilloni
Honored Contributor

Re: date manipulation

great! my first smiling rabbit
... and a little english lesson :-)

tx
Claudio
Jarle Bjorgeengen
Trusted Contributor

Re: date manipulation

Hi,

the idea was something like this.

$let last_month=$(date +%m)-1
$echo $last_month

Rgds Jarle