Sponsored Content
Top Forums Shell Programming and Scripting Use date command to find last month Post 302131386 by lorcan on Friday 10th of August 2007 09:54:58 AM
Old 08-10-2007
Code:
echo $(date -d"1 month ago" "+%G%m%d" | cut -c5-6)

or

Code:
echo $(date -d"1 month ago" "+%m" )

 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

find out month from a date

I would like to find out the month from a given date, how is it possible. (5 Replies)
Discussion started by: rudoraj
5 Replies

2. Shell Programming and Scripting

How to find the create time of a file if current date is in next month

Hi All, I want to find the time diffrence between currnt time and "abc.txt" file create time. I have solve that but if the abc.txt file created last month then is there any process to find the difftent? Exp: Create time of abc.txt is "Apr 14 06:48" and currect date is "May 17 23:47".... (1 Reply)
Discussion started by: priyankak
1 Replies

3. UNIX for Dummies Questions & Answers

Date command to obtain the last month is not working correctly..

Hello, I could not find the exactly same post here.. so I will explain what I did to get the last month using date command. I used date +%Y-%m -d "-1 months" to get the last month. However, the returned value of above command on 2009/10/31 was 2009 10 and not 2009 09.. and the... (9 Replies)
Discussion started by: tigersk
9 Replies

4. UNIX for Dummies Questions & Answers

print previous month (current month minus 1) with Solaris date and ksh

Hi folks month=`date +%m`gives current month Howto print previous month (current month minus 1) with Solaris date and ksh (7 Replies)
Discussion started by: slashdotweenie
7 Replies

5. UNIX for Dummies Questions & Answers

date command - getting previous month

Hi, On any given day, I want to capture the month that has gone by - said otherwise, how do I capture last month? expr date '+%m' - 1 Above expression is giving error. Please advise thanks ---------- Post updated at 09:28 AM ---------- Previous update was at 09:11 AM... (1 Reply)
Discussion started by: ab_2010
1 Replies

6. UNIX for Dummies Questions & Answers

Unix man command to find out month of the year?

how can i display month of the year i was born with using man command? thanks (2 Replies)
Discussion started by: janetroop95
2 Replies

7. Shell Programming and Scripting

Help with getting last date of previous month and first date of previous 4th month from current date

I have requirment to get last date of previous month and the first date of previous 4th month: Example: Current date: 20130320 (yyyymmdd) Last date of previous month: 20130228 (yyyymmdd) First date of previous 4th month: 20121101 (yyyymmdd) In my shell --date, -d, -v switches are not... (3 Replies)
Discussion started by: machomaddy
3 Replies

8. Red Hat

How to find/display out last Friday's date of the month?

Hello, Can you please help me find/display out last Friday's date of the month using command in Unix/Linux (3 Replies)
Discussion started by: sunnysthakur
3 Replies

9. Shell Programming and Scripting

How to find all files other than first two dates & last date per month and year?

how to find all files other than first two dates & last date per month and year Hi All, lets say there are following files in directory -rwxr-xr-x 1 user userg 1596 Mar 19 2012 a.txt -rwxr-xr-x 1 user userg 1596 Mar 19 2012 b.txt -rwxr-xr-x 1 user userg ... (6 Replies)
Discussion started by: Makarand Dodmis
6 Replies

10. Shell Programming and Scripting

Find one month before date

Hi, I want two dates one will be the current date and the other one will be just one month before. Say if current month is 11/4/2014 then the other date should be 11/3/2014. #!/bin/ksh currentDtae=`date` oneMonthBefore= ? I dont know how to do it. Went through some of the related threads... (15 Replies)
Discussion started by: Sharma331
15 Replies
calendar(1)						      General Commands Manual						       calendar(1)

NAME
calendar - reminder service SYNOPSIS
DESCRIPTION
consults the file in the current directory and prints out lines containing today's or tomorrow's date anywhere in the line. On weekends, ``tomorrow'' extends through Monday. When a command-line argument is present, searches for the file in each user's home directory, and sends any positive results to the user by (see mail(1)). Normally this is done daily in the early morning hours under the control of (see cron(1M)). When invoked by reads the first line in the file to determine the user's environment. Language-dependent information such as spelling and date format (described below) are determined by the user-specified statement in the file. This statement should be of the form where language is a valid language name (see lang(5)). If this line is not in the file, the action described in the section is taken. is concerned with two fields: month and day. A month field can be expressed in three different formats: a string representing the name of the month (either fully spelled out or abbreviated), a numeric month, or an asterisk (representing any month). If the month is expressed as a string representing the name of the month, the first character can be either upper-case or lower-case; other characters must be lower- case. The spelling of a month name should match the string returned by calling (see nl_langinfo(3C)). The day field is a numeric value for the day of the month. Month-Day Formats If the month field is a string, it can be followed by zero or more blanks. If the month field is numeric, it must be followed by either a slash or a hyphen If the month field is an asterisk it must be followed by a slash The day field can be followed immediately by a blank or non-digit character. Day-Month Formats The day field is expressed as a numeral. What follows the day field is determined by the format of the month. If the month field is a string, the day field must be followed by zero or one dot followed by zero or more blanks. If the month field is a numeral, the day field must be followed by either a slash or a hyphen If the month field is an asterisk, the day field must be followed by a slash EXTERNAL INFLUENCES
Environment Variables determines the format and contents of date and time strings when no statement is specified in the file. determines the language in which messages are displayed. If is not specified in the environment or is set to the empty string, the value of is used as a default for each unspecified or empty vari- able. If is not specified or is set to the empty string, a default of "C" (see lang(5)) is used instead of If any internationalization variable contains an invalid setting, behaves as if all internationalization variables are set to "C". See environ(5). International Code Set Support Single- and multi-byte character code sets are supported. EXAMPLES
The following file illustrates several formats recognized by calendar: In the following file, dates are expressed according to European English usage: WARNINGS
To get reminder service, either your calendar must be public information or you must run from your personal file, independent of any run systemwide. Note that if you run yourself, the calendar file need not reside in your home directory. extended idea of ``tomorrow'' does not account for holidays. This command is likely to be withdrawn from X/Open standards. Applications using this command might not be portable to other vendors' platforms. AUTHOR
was developed by AT&T and HP. FILES
to figure out today's and tomorrow's dates SEE ALSO cron(1M), nl_langinfo(3C), mail(1), environ(5). STANDARDS CONFORMANCE
calendar(1)
All times are GMT -4. The time now is 12:59 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy