Sponsored Content
Top Forums Shell Programming and Scripting UNIX date fuction - how to deduct days from today's date Post 302811391 by juzz4fun on Thursday 23rd of May 2013 01:27:22 PM
Old 05-23-2013
UNIX date fuction - how to deduct days from today's date

Hi,

One of my Unix scripts needs to look for files coming in on Fridays. This script runs on Mondays. $date +"%y%m%d" will give me today's date. How can I get previous Friday's date.. can I do "today's date minus 3 days" to get Friday's date? If not, then any other way?? Name of the files is in the format.. A130524.csv, and I am expected to get one file every month.

~juzz4fun
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

compare today's date with date in a file

Hi I am very new to scripting, Can someone show me how to (in unix shell script) compare the system's date with a date in a file. The requirement is to somehow open this file (which will only have a date in it) and compare it with today's date. If they are equal execute a procedure below but if... (4 Replies)
Discussion started by: siog
4 Replies

2. Shell Programming and Scripting

Calculate 30/31 days from today date script

Hi Guys, I was working some time ago n was in need to calculate date 30/31 days from today including Feb (Leap yr stuff). Today date is variable depending on day of execution of script. I tried searching but was not able to get exactly what I needed....So at that I time I implemented by my own... (3 Replies)
Discussion started by: coolgoose85
3 Replies

3. Shell Programming and Scripting

how to get what date was 28 days ago of the current system date IN UNIX

Hi, Anybody knows how to get what date was 28 days ago of the current system date through UNIX script. Ex : - If today is 28th Mar 2010 then I have to delete the files which arrived on 1st Mar 2010, (15 Replies)
Discussion started by: kandi.reddy
15 Replies

4. Shell Programming and Scripting

Number of days between the current date and user defined date

I am trying to find out the number of days between the current date and user defined date. I took reference from here for the date2jd() function. Modified the function according to my requirement. But its not working properly. Original code from here is working fine. #!/bin/sh... (1 Reply)
Discussion started by: hiten.r.chauhan
1 Replies

5. UNIX for Dummies Questions & Answers

Shell Scripts - shows today’s date and time in a better format than ‘date’ (Uses positional paramete

Hello, I am trying to show today's date and time in a better format than ‘date' (Using positional parameters). I found a command mktime and am wondering if this is the best command to use or will this also show me the time elapse since 1/30/70? Any help would be greatly appreciated, Thanks... (3 Replies)
Discussion started by: citizencro
3 Replies

6. Shell Programming and Scripting

[Solved] Replace yesterday date with today's date except from the first line

Hello, I have a file like this: 2012112920121130 12345620121130msABowwiqiq 34477420121129amABamauee e7748420121130ehABeheheei in case the content of the file has the date of yesterday within the lines containing pattern AB this should be replaced by the current date. But if I use... (3 Replies)
Discussion started by: Lilu_CK
3 Replies

7. Shell Programming and Scripting

Need to add a date column (today's date) in file

Hi I have file with number status and date1 and date1 field, want add a column today between column date1 and date2. file1.txt number status date1 date2 ===== ==== === ===== 34567 open 27/06/13 28/06/13 45678 open 27/06/13 28/06/13 43567 open 27/06/13 28/06/13 ... (1 Reply)
Discussion started by: vijay_rajni
1 Replies

8. Shell Programming and Scripting

Get business days including today's date

I am trying to get last 5 business day . trying for d in Mon Tue Wed Thu Fri do date +%Y%m%d -d "last $d" done gives me date Thu Oct 20 23:56:26 EDT 2016 20161017 20161018 20161019 20161013 20161014 expected output should be 20161017 20161018 20161019 20161020 (2 Replies)
Discussion started by: abhii
2 Replies

9. HP-UX

awk command in hp UNIX subtract 30 days automatically from current date without date illegal option

current date command runs well awk -v t="$(date +%Y-%m-%d)" -F "'" '$1 < t' myname.dat subtract 30 days fails awk -v t="$(date --date="-30days" +%Y-%m-%d)" -F "'" '$1 < t' myname.dat awk command in hp unix subtract 30 days automatically from current date without date illegal option error... (20 Replies)
Discussion started by: kmarcus
20 Replies

10. UNIX for Beginners Questions & Answers

Compare Date to today's date in shell script

Hi Community! Following on from this code in another thread: #!/bin/bash file_string=`/bin/cat date.txt | /usr/bin/awk '{print $5,$4,$7,$6,$8}'` file_date=`/bin/date -d "$file_string"` file_epoch=`/bin/date -d "$file_string" +%s` now_epoch=`/bin/date +%s` if then #let... (2 Replies)
Discussion started by: Greenage
2 Replies
CALENDAR(1)						    BSD General Commands Manual 					       CALENDAR(1)

NAME
calendar -- reminder service SYNOPSIS
calendar [-ab] [-A num] [-B num] [-l num] [-w num] [-f calendarfile] [-t [[[cc]yy]mm]dd] DESCRIPTION
The calendar utility checks the current directory or the directory specified by the CALENDAR_DIR environment variable for a file named calendar and displays lines that begin with either today's date or tomorrow's. On Fridays, events on Friday through Monday are displayed. The options are as follows: -A num Print lines from today and next num days (forward, future). Defaults to one. (same as -l) -a Process the ``calendar'' files of all users and mail the results to them. This requires superuser privileges. -B num Print lines from today and previous num days (backward, past). -b Enforce special date calculation mode for KOI8 calendars. -l num Print lines from today and next num days (forward, future). Defaults to one. (same as -A) -w num Print lines from today and next num days, only if today is Friday (forward, future). Defaults to two, which causes calendar to print entries through the weekend on Fridays. -f calendarfile Use calendarfile as the default calendar file. -t [[[cc]yy]mm]dd Act like the specified value is ``today'' instead of using the current date. If yy is specified, but cc is not, a value for yy between 69 and 99 results in a cc value of 19. Otherwise, a cc value of 20 is used. To handle calendars in your national code table you can specify ``LANG=<locale_name>'' in the calendar file as early as possible. To handle national Easter names in the calendars, ``Easter=<national_name>'' (for Catholic Easter) or ``Paskha=<national_name>'' (for Orthodox Easter) can be used. A special locale name exists: 'utf-8'. Specifying ``LANG=utf-8'' indicates that the dates will be read using the C locale, and the descrip- tions will be encoded in UTF-8. This is usually used for the distributed calendar files. The ``CALENDAR'' variable can be used to specify the style. Only 'Julian' and 'Gregorian' styles are currently supported. Use ``CALENDAR='' to return to the default (Gregorian). To enforce special date calculation mode for Cyrillic calendars you should specify ``LANG=<local_name>'' and ``BODUN=<bodun_prefix>'' where <local_name> can be ru_RU.KOI8-R, uk_UA.KOI8-U or by_BY.KOI8-B. Note that the locale is reset to the user's default for each new file that is read. This is so that locales from one file do not accidentally carry over into another file. Other lines should begin with a month and day. They may be entered in almost any format, either numeric or as character strings. If proper locale is set, national months and weekdays names can be used. A single asterisk (`*') matches every month. A day without a month matches that day of every week. A month without a day matches the first of that month. Two numbers default to the month followed by the day. Lines with leading tabs default to the last entered date, allowing multiple line specifications for a single date. ``Easter'' (may be followed by a positive or negative integer) is Easter for this year. ``Paskha'' (may be followed by a positive or negative integer) is Orthodox Easter for this year. Weekdays may be followed by ``-4'' ... ``+5'' (aliases last, first, second, third, fourth) for moving events like ``the last Monday in April''. By convention, dates followed by an asterisk ('*') are not fixed, i.e., change from year to year. Day descriptions start after the first <tab> character in the line; if the line does not contain a <tab> character, it isn't printed out. If the first character in the line is a <tab> character, it is treated as the continuation of the previous description. The calendar file is preprocessed by cpp(1), allowing the inclusion of shared files such as company holidays or meetings. If the shared file is not referenced by a full pathname, cpp(1) searches in the current (or home) directory first, and then in the directory directory /etc/calendar, and finally in /usr/share/calendar. Empty lines and lines protected by the C commenting syntax (/* ... */) are ignored. Some possible calendar entries (a sequence denotes a <tab> character): LANG=C Easter=Ostern #include <calendar.usholiday> #include <calendar.birthday> 6/15 June 15 (if ambiguous, will default to month/day). Jun. 15 June 15. 15 June June 15. Thursday Every Thursday. June Every June 1st. 15 * 15th of every month. May Sun+2 second Sunday in May (Muttertag) 04/SunLast last Sunday in April, summer time in Europe Easter Easter Ostern-2 Good Friday (2 days before Easter) Paskha Orthodox Easter FILES
calendar File in current directory. ~/.calendar Directory in the user's home directory (which calendar changes into, if it exists). ~/.calendar/calendar File to use if no calendar file exists in the current directory. ~/.calendar/nomail calendar will not send mail if this file exists. calendar.all International and national calendar files. calendar.birthday Births and deaths of famous (and not-so-famous) people. calendar.christian Christian holidays (should be updated yearly by the local system administrator so that roving holidays are set cor- rectly for the current year). calendar.computer Days of special significance to computer people. calendar.croatian Croatian calendar. calendar.discord Discordian calendar (all rites reversed). calendar.fictional Fantasy and fiction dates (mostly LOTR). calendar.french French calendar. calendar.german German calendar. calendar.history Miscellaneous history. calendar.holiday Other holidays (including the not-well-known, obscure, and really obscure). calendar.judaic Jewish holidays (should be updated yearly by the local system administrator so that roving holidays are set correctly for the current year). calendar.music Musical events, births, and deaths (strongly oriented toward rock n' roll). calendar.openbsd OpenBSD related events. calendar.pagan Pagan holidays, celebrations and festivals. calendar.russian Russian calendar. calendar.space Cosmic history. calendar.ushistory U.S. history. calendar.usholiday U.S. holidays. calendar.world World wide calendar. SEE ALSO
at(1), cal(1), cpp(1), mail(1), cron(8) STANDARDS
The calendar program previously selected lines which had the correct date anywhere in the line. This is no longer true: the date is only recognized when it occurs at the beginning of a line. COMPATIBILITY
The calendar command will only display lines that use a <tab> character to separate the date and description, or that begin with a <tab>. This is different than in previous releases. The -t flag argument syntax is from the original FreeBSD calendar program. The -l and -w flags are Debian-specific enhancements. Also, the original calendar program did not accept 0 as an argument to the -A flag. Using 'utf-8' as a locale name is a Debian-specific enhancement. HISTORY
A calendar command appeared in Version 7 AT&T UNIX. BUGS
calendar doesn't handle all Jewish holidays or moon phases. BSD
September 13, 2011 BSD
All times are GMT -4. The time now is 06:33 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy