Sponsored Content
Top Forums Shell Programming and Scripting Help, I need to get the last date of previous month Post 302170340 by Tytalus on Monday 25th of February 2008 09:48:37 AM
Old 02-25-2008
continuing in the style of your script try using code like:

Code:
/bin/cal $prev_month $cur_year | grep -v "^$" | sed -n  '1p;$p' | tr "\n" " "  | awk '{print substr($1,1,3),$NF,$2}'

HTH
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

file name using previous month

This has probably been asked 100 times, but I couldn't find any articles on point. I have a script that runs on the last day of every month at 11:30pm. If cats a number of input tables that were created the previous month (or earlier), combines them into one master file and erases the indivual... (1 Reply)
Discussion started by: beilstwh
1 Replies

2. Shell Programming and Scripting

How to get previous month files

Hi, My task to to delete files which are of previous months. I have files named as follows *CCYYMMDD.xls. on a particular day i have delete previous months files i.e in Dec i have delete all nov files which look like 200511DD.XLS in Jan i have to delete all Dec files 200512DD.xls ... (7 Replies)
Discussion started by: savitha
7 Replies

3. Shell Programming and Scripting

needs to display month for previous day date

Hello, I wanted to display the month for previous day date. Like, today date is 18-Nov-2008. So the previous date is 17-Nov-2008. The output should be November. If the today date is 1-DEC-2008, then output should be NOVEMBER. If the today date is 1-JAN-2008, then output should be DECEMBER.... (4 Replies)
Discussion started by: govindts
4 Replies

4. UNIX for Dummies Questions & Answers

How to get the previous month by using `date`

Hello, I'm new to shell scripting. We've develop a script which will grep a file on the search criteria, MON (Jan/Feb/Mar/etc). But we should set this sript in cron which will run on every first day of the month. The problem I'm having is, when I run the script, it is displaying the contents of... (7 Replies)
Discussion started by: suneelj
7 Replies

5. Shell Programming and Scripting

Pass the first date and last date of previous month

Hi All, I need to run a job every month at the beginning of the month which is scheduled through autosys, lets say on 03/01/2010. I need to pass the last month's i.e February's first_date = 02/01/2010 and last_date = 02/28/2010 as variables to a stored procedure. Can somebody please pass... (2 Replies)
Discussion started by: vigdmab
2 Replies

6. 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

7. 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

8. UNIX for Dummies Questions & Answers

Get the previous month from date

Hi All, I am using the below code to get the year and month from date: Below gives output like 201212. dt=`date '+%Y%m'` how do i get the previous month value(ie: subtract 1 from date) example output: dt=201211 Please help. :confused: (3 Replies)
Discussion started by: abhi_123
3 Replies

9. 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

10. Shell Programming and Scripting

Not able to fetch previous month first date and last date

I am not able to fetch first date and last date previous month date -d -1month +%Y-%m-%d date -d -1month +%Y-%m-%d I need two format dd-mm-yyy previous month 01-03-2016 previous month 31-03-2016 and also only date 1 to 31 Aprriciate your replay (4 Replies)
Discussion started by: jagu
4 Replies
GMMKTIME(3)								 1							       GMMKTIME(3)

gmmktime - Get Unix timestamp for a GMT date

SYNOPSIS
int gmmktime ([int $hour = gmdate("H")], [int $minute = gmdate("i")], [int $second = gmdate("s")], [int $month = gmdate("n")], [int $day = gmdate("j")], [int $year = gmdate("Y")], [int $is_dst = -1]) DESCRIPTION
Identical to mktime(3) except the passed parameters represents a GMT date. gmmktime(3) internally uses mktime(3) so only times valid in derived local time can be used. Like mktime(3), arguments may be left out in order from right to left, with any omitted arguments being set to the current corresponding GMT value. PARAMETERS
o $hour - The number of the hour relative to the start of the day determined by $month, $day and $year. Negative values reference the hour before midnight of the day in question. Values greater than 23 reference the appropriate hour in the following day(s). o $minute - The number of the minute relative to the start of the $hour. Negative values reference the minute in the previous hour. Values greater than 59 reference the appropriate minute in the following hour(s). o $second - The number of seconds relative to the start of the $minute. Negative values reference the second in the previous minute. Values greater than 59 reference the appropriate second in the following minute(s). o $month - The number of the month relative to the end of the previous year. Values 1 to 12 reference the normal calendar months of the year in question. Values less than 1 (including negative values) reference the months in the previous year in reverse order, so 0 is December, -1 is November, etc. Values greater than 12 reference the appropriate month in the following year(s). o $day - The number of the day relative to the end of the previous month. Values 1 to 28, 29, 30 or 31 (depending upon the month) refer- ence the normal days in the relevant month. Values less than 1 (including negative values) reference the days in the previous month, so 0 is the last day of the previous month, -1 is the day before that, etc. Values greater than the number of days in the relevant month reference the appropriate day in the following month(s). o $year - The year o $is_dst - Parameters always represent a GMT date so $is_dst doesn't influence the result. Note This parameter has been removed in PHP 7.0.0. RETURN VALUES
Returns a integer Unix timestamp. CHANGELOG
+--------+---------------------------------------------------+ |Version | | | | | | | Description | | | | +--------+---------------------------------------------------+ | 7.0.0 | | | | | | | $is_dst parameter has been removed. | | | | | 5.1.0 | | | | | | | As of PHP 5.1.0, the $is_dst parameter became | | | deprecated. As a result, the new timezone han- | | | dling features should be used instead. | | | | +--------+---------------------------------------------------+ EXAMPLES
Example #1 gmmktime(3) basic example <?php // Prints: July 1, 2000 is on a Saturday echo "July 1, 2000 is on a " . date("l", gmmktime(0, 0, 0, 7, 1, 2000)); ?> SEE ALSO
mktime(3), date(3), time(3). PHP Documentation Group GMMKTIME(3)
All times are GMT -4. The time now is 05:08 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy