Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Need to go back 1 day using the date command Post 7601 by cfoxwell on Friday 28th of September 2001 04:48:27 AM
Old 09-28-2001
Need to go back 1 day using the date command

I am trying to write a shell script to look at log files with dates in the file name.

Now I know how to use the expr command to subtract 1 day from the other, which is simple when the dates are from the 2nd to the 31st of each month.

But the problem I have is when the date turns to the 1st and the last month is 31st or 30th - because 1 -1 = -1 don't it, rather than 30 or 31

How do I write a script to handle this.

P.S I'm using KSH
 

8 More Discussions You Might Find Interesting

1. Filesystems, Disks and Memory

Can I back up all the files I work with each day using tar?

Can I back up all the files I work with each day using tar? (2 Replies)
Discussion started by: jo calamine
2 Replies

2. Shell Programming and Scripting

to find all files created a day back

Hi Guys, My unix is SunOS. I like to find all the files which are created 1 day back. i tried the following command find . -type f -name '*.aud' -mtime +1 This gives me all the files created 48 hours back (2 days) but not one.. Can you let me know where i am going wrong. Thanks,... (8 Replies)
Discussion started by: mac4rfree
8 Replies

3. Shell Programming and Scripting

how to obtain date and day of the week from `date` command

Hi, does anybody know how to format `date` command correctly to return the day of the week? Thanks -A I work in ksh.... (1 Reply)
Discussion started by: aoussenko
1 Replies

4. Shell Programming and Scripting

finding the previous day date and creating a file with date

Hi guys, I had a scenario... 1. I had to get the previous days date in yyyymmdd format 2. i had to create a file with Date inthe format yyyymmdd.txt format both are different thanks guys in advance.. (4 Replies)
Discussion started by: apple2685
4 Replies

5. Shell Programming and Scripting

Fetch date of 7 years back from current date in Perl

$beginDate = substr(DateCalc("today", "-7Days"),0,8); This fetches the date 7 days back Can I fetch the date before 7 years from todays date in Perl using same syntax Use code tags, see PM. (3 Replies)
Discussion started by: parthmittal2007
3 Replies

6. AIX

Need to get the next day's date of the user entered date

I need to get the next day's date of the user entered date for example: Enter date (yyyy/mm/yy): 2013/10/08I need to get the next day's date of the user entered date Desired Output: 2013/10/09Though there are ways to achieve this is Linux or Unix environment (date command) ,I need to... (1 Reply)
Discussion started by: rpm120
1 Replies

7. UNIX for Dummies Questions & Answers

[Solved] Using date command, getting previous day

Legends, i need to get previous day using date command. Can you please help. sdosanjh:/home> date +%m%d%y 011514 i tried -d '-1 day' but it is not working (5 Replies)
Discussion started by: sdosanjh
5 Replies

8. UNIX for Beginners Questions & Answers

Replace date in file every day with current date

I Have text like XXX_20190908.csv.gz need to replace Only date in this format with current date every day Thanks! (1 Reply)
Discussion started by: yamasani1991
1 Replies
HTML::CalendarMonth::DateTool(3pm)			User Contributed Perl Documentation			HTML::CalendarMonth::DateTool(3pm)

NAME
HTML::CalendarMonth::DateTool - Base class for determining which date package to use for calendrical calculations. SYNOPSIS
my $date_tool = HTML::CalendarMonth::DateTool->new( year => $YYYY_year, month => $one_thru_12_month, weeknum => $weeknum_mode, historic => $historic_mode, datetool => $specific_datetool_if_desired, ); DESCRIPTION
This module attempts to utilize the best date calculation package available on the current system. For most contemporary dates this usually ends up being the internal Time::Local package of perl. For more exotic dates, or when week number of the years are desired, other methods are attempted including DateTime, Date::Calc, Date::Manip, and the linux/unix 'ncal' or 'cal' commands. Each of these has a specific subclass of this module offering the same utility methods needed by HTML::CalendarMonth. METHODS
new() Constructor. Takes the following parameters: year Year of calendar in question (required). If you are rendering exotic dates (i.e. dates outside of 1970 to 2038) then something besides Time::Local will be used for calendrical calculations. month Month of calendar in question (required). 1 through 12. weeknum Optional. When specified, will limit class excursions to those that are currently set up for week of year calculations. historic Optional. If the the ncal or cal commands are available, use one of them rather than other available date modules since these utilities accurately handle some specific historical artifacts such as the transition from Julian to Gregorian. datetool Optional. Mostly for debugging, this option can be used to indicate a specific HTML::CalendarMonth::DateTool subclass for instantiation. The value can be either the actual utility class, e.g., Date::Calc, or the name of the CalendarMonth handler leaf class, e.g. DateCalc. Use 'ncal' or 'cal', respectively, for the wrappers around those commands. There are number of methods automatically available: month() year() weeknum() historical() datetool() Accessors for the parameters provided to "new()" above. dow1st() Returns the day of week number for the 1st of the "year" and "month" specified during the call to "new()". Relies on the presence of "dow1st_and_lastday()". Should be 0..6 starting with Sun. lastday() Returns the last day of the month for the "year" and "month" specified during the call to "new()". Relies on the presence of "dow1st_and_lastday()". Overridden methods Subclasses of this module must provide at least the "day_epoch()" and "dow1st_and_lastday()" methods. dow1st_and_lastday() Required. Provides a list containing the day of the week of the first day of the month (0..6 starting with Sun) along with the last day of the month. day_epoch() Optional unless interested in epoch values for wacky dates. For a given day, and optionally "month" and "year" if they are different from those specified in "new()", provide the unix epoch in seconds for that day at midnight. If the subclass is expected to provide week of year numbers, three more methods are necessary: dow() For a given day, and optionally "month" and "year" if they are different from those specified in "new()", provide the day of week number. (1=Sunday, 7=Saturday). add_days($days, $delta, $day, [$month], [$year]) For a given day, and optionally "month" and "year" if they are different from those specified in "new()", provide a list of year, month, and day once "delta" days have been added. week_of_year($day, [$month], [$year]) For a given day, and optionally "month" and "year" if they are different from those specified in "new()", provide a list with the week number of the year along with the year. (some days of a particular year can end up belonging to the prior or following years). AUTHOR
Matthew P. Sisk, <sisk@mojotoad.com> COPYRIGHT
Copyright (c) 2010 Matthew P. Sisk. All rights reserved. All wrongs revenged. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. SEE ALSO
HTML::CalendarMonth(3), Time::Local(3), DateTime(3), Date::Calc(3), Date::Manip(3), cal(1) perl v5.12.4 2011-08-26 HTML::CalendarMonth::DateTool(3pm)
All times are GMT -4. The time now is 04:55 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy