LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 05-31-2015, 10:43 PM   #1
byran cheung
Member
 
Registered: Sep 2013
Posts: 321

Rep: Reputation: Disabled
Display last month


I know the command many display current month and year .

Code:
#date +%b%Y

Jun2015
If I want to show the last month and year ( as current month is Jun2015, I would like display May2015 , if current is Jan2016 , then display Dec2015 ) , would advise what can I do ? thanks
 
Old 06-01-2015, 01:20 AM   #2
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,126

Rep: Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120
"man date" - go to the bottom.
 
1 members found this post helpful.
Old 06-01-2015, 09:54 AM   #3
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,634

Rep: Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965
Quote:
Originally Posted by byran cheung View Post
I know the command many display current month and year .
Code:
#date +%b%Y

Jun2015
If I want to show the last month and year ( as current month is Jun2015, I would like display May2015 , if current is Jan2016 , then display Dec2015 ) , would advise what can I do ? thanks
You can look up any of the easily-found examples with a brief Google search, and show some effort of your own, as you've been asked to do MANY times in MANY other threads you've posted.

Read the "Question Guidelines" link in my posting signature.
 
Old 06-01-2015, 12:18 PM   #4
Habitual
LQ Veteran
 
Registered: Jan 2011
Location: Abingdon, VA
Distribution: Catalina
Posts: 9,374
Blog Entries: 37

Rep: Reputation: Disabled
Ah, date magic, gotta love it. I keep a collection of this stuff
tips and clues and format are here...
 
Old 06-24-2015, 09:51 PM   #5
dslackw
Member
 
Registered: Aug 2014
Location: Orestiada, GR
Distribution: Slackware 15.0 x86_64 -stable
Posts: 158

Rep: Reputation: 44
Code:
date --date="-1 month" +"%B%Y"

Last edited by dslackw; 06-24-2015 at 09:53 PM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to display the current month using cal hello111 Linux - Newbie 20 10-15-2014 10:20 PM
Display the percentage of increase in data size for each month Bunty2013 Linux - Newbie 2 10-21-2013 12:21 PM
How to find/display out last Friday's date of the month sunnysthakur Linux - General 11 03-29-2013 03:09 AM
LXer: CodeWeavers CEO names himself employee of the month for 175TH consecutive month LXer Syndicated Linux News 3 08-13-2010 04:55 PM
display month format in 2 digit coolplanet Programming 7 06-07-2009 08:55 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 01:44 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration