02-13-2017
This isn't being done by BASH, everything here is being done by date - GNU date specifically. Basic POSIX date doesn't have "+ 3 days" (but in my opinion, should.)
GNU date - and most of the civilized world sincd 1988 - understand dates in the ISO standard YYYY/MM/DD form. This method has pretty clear advantages like dates being trivially sortable. So you could do -d "2016/12/31 + 3 days", etc.
Last edited by Corona688; 02-13-2017 at 12:14 PM..
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Hi expert,
I want to retrieve yesterday su log.
How to calculate and assign variable value ( 06/23 ) in myVariable ?
#!/bin/sh
myVariable=yesterday date in month/date
cat /var/adm/sulog | grep $myVariable > file.txt
many thanks! (5 Replies)
Discussion started by: skully
5 Replies
2. Shell Programming and Scripting
Dear All,
Actually, i'm doing some reporting job and i need to pass yesterday's date in Year-Month-Day format(e.g. 2009-06-10) to another program for generating 2009-06-10 report.
to get today's date, it's easy to just date '+%Y%m%d' , but no idea how can i get this kind of format for... (2 Replies)
Discussion started by: tiger2000
2 Replies
3. Homework & Coursework Questions
1. The problem statement, all variables and given/known data:
I have standard web server log file. It contains different columns (like IP address, request result code, request type etc) including a date column with the format .
I have developed a log analysis command line utility that displays... (1 Reply)
Discussion started by: TariqYousaf
1 Replies
4. Shell Programming and Scripting
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
5. UNIX for Dummies Questions & Answers
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
6. Shell Programming and Scripting
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
7. Shell Programming and Scripting
Hi All,
I need to find all files other than first two files dates & last file date for month and month/year wise list.
lets say there are following files in directory
Mar 19 2012 c.txt
Mar 19 2012 cc.txt
Mar 21 2012 d.txt
Mar 22 2012 f.txt
Mar 24 2012 h.txt
Mar 25 2012 w.txt
Feb 12... (2 Replies)
Discussion started by: Makarand Dodmis
2 Replies
8. Shell Programming and Scripting
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
9. Shell Programming and Scripting
Hi all,
Need an urgent help on the below scenario.
script:
awk -F","
'BEGIN { #some variable assignment}
{ #some calculation and put values in array}
END {
year=#getting it from array and assume this will be 2014
month=#getting it from array and this will be 05
date=#... (7 Replies)
Discussion started by: vijaidhas
7 Replies
10. Shell Programming and Scripting
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
CAL(1) BSD General Commands Manual CAL(1)
NAME
cal, ncal -- displays a calendar and the date of Easter
SYNOPSIS
cal [-3hjy] [-A number] [-B number] [[month] year]
cal [-3hj] [-A number] [-B number] -m month [year]
ncal [-3hjJpwy] [-A number] [-B number] [-s country_code] [[month] year]
ncal [-3hJeo] [-A number] [-B number] [year]
ncal [-CN] [-H yyyy-mm-dd] [-d yyyy-mm]
DESCRIPTION
The cal utility displays a simple calendar in traditional format and ncal offers an alternative layout, more options and the date of Easter.
The new format is a little cramped but it makes a year fit on a 25x80 terminal. If arguments are not specified, the current month is dis-
played.
The options are as follows:
-h Turns off highlighting of today.
-J Display Julian Calendar, if combined with the -e option, display date of Easter according to the Julian Calendar.
-e Display date of Easter (for western churches).
-j Display Julian days (days one-based, numbered from January 1).
-m month
Display the specified month. If month is specified as a decimal number, it may be followed by the letter 'f' or 'p' to indicate the
following or preceding month of that number, respectively.
-o Display date of Orthodox Easter (Greek and Russian Orthodox Churches).
-p Print the country codes and switching days from Julian to Gregorian Calendar as they are assumed by ncal. The country code as deter-
mined from the local environment is marked with an asterisk.
-s country_code
Assume the switch from Julian to Gregorian Calendar at the date associated with the country_code. If not specified, ncal tries to
guess the switch date from the local environment or falls back to September 2, 1752. This was when Great Britain and her colonies
switched to the Gregorian Calendar.
-w Print the number of the week below each week column.
-y Display a calendar for the specified year.
-3 Display the previous, current and next month surrounding today.
-A number
Display the number of months after the current month.
-B number
Display the number of months before the current month.
-C Switch to cal mode.
-N Switch to ncal mode.
-d yyyy-mm
Use yyyy-mm as the current date (for debugging of date selection).
-H yyyy-mm-dd
Use yyyy-mm-dd as the current date (for debugging of highlighting).
A single parameter specifies the year (1-9999) to be displayed; note the year must be fully specified: ``cal 89'' will not display a calendar
for 1989. Two parameters denote the month and year; the month is either a number between 1 and 12, or a full or abbreviated name as speci-
fied by the current locale. Month and year default to those of the current system clock and time zone (so ``cal -m 8'' will display a calen-
dar for the month of August in the current year).
Not all options can be used together. For example ``-3 -A 2 -B 3 -y -m 7'' would mean: show me the three months around the seventh month,
three before that, two after that and the whole year. ncal will warn about these combinations.
A year starts on January 1.
Highlighting of dates is disabled if stdout is not a tty.
SEE ALSO
calendar(3), strftime(3)
HISTORY
A cal command appeared in Version 5 AT&T UNIX. The ncal command appeared in FreeBSD 2.2.6.
AUTHORS
The ncal command and manual were written by Wolfgang Helbig <helbig@FreeBSD.org>.
BUGS
The assignment of Julian-Gregorian switching dates to country codes is historically naive for many countries.
Not all options are compatible and using them in different orders will give varying results.
BSD
March 14, 2009 BSD