LinuxQuestions.org
Help answer threads with 0 replies.
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, 11: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, 02:20 AM   #2
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 16,001

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

Rep: Reputation: 4473Reputation: 4473Reputation: 4473Reputation: 4473Reputation: 4473Reputation: 4473Reputation: 4473Reputation: 4473Reputation: 4473Reputation: 4473Reputation: 4473
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, 01:18 PM   #4
Habitual
LQ 5k Club
 
Registered: Jan 2011
Location: Nowhere near you, thank God.
Distribution: High Sierra
Posts: 8,599
Blog Entries: 15

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, 10:51 PM   #5
dslackw
Member
 
Registered: Aug 2014
Location: Orestiada, GR
Distribution: Slackware 14.1 x86_64 -stable
Posts: 145

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

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


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 11:20 PM
Display the percentage of increase in data size for each month Bunty2013 Linux - Newbie 2 10-21-2013 01:21 PM
How to find/display out last Friday's date of the month sunnysthakur Linux - General 11 03-29-2013 04:09 AM
LXer: CodeWeavers CEO names himself employee of the month for 175TH consecutive month LXer Syndicated Linux News 3 08-13-2010 05:55 PM
display month format in 2 digit coolplanet Programming 7 06-07-2009 09:55 PM

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

All times are GMT -5. The time now is 02:16 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration