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
calendar(1)						      General Commands Manual						       calendar(1)

Name
       calendar - calendar reminder service

Syntax
       calendar [-]

Description
       The  command  consults the file `calendar' in the current directory and prints out lines that contain today's or tomorrow's date.  The com-
       mand recognizes most month-day dates, such as Dec. 7, december 7, 12/7, but it does not recognize dates formatted in the following ways:  7
       December  or  7/12.  If you give the month as * with a date, such as, * 1, that day in any month will do.  On weekends, specifying tomorrow
       extends through Monday.

       When an argument is present, the command searches through a user's calendar file in his login directory and sends him any positive  results
       by Normally this is done daily under control of

       The  calendar  file  is	first  run  through  the  C  preprocessor, to include any other calendar files specified with the #include syntax.
       Included calendars are shared by all users, and are maintained and documented by the local administration.

Options
       -    Functions for every user who has a calendar file in his login directory.

Restrictions
       The extended idea of tomorrow does not account for holidays.

Files
       calendar
       /usr/lib/calendar to figure out today's and tomorrow's dates
       /etc/passwd
       /tmp/cal*
       /lib/cpp, egrep, sed, mail as subprocesses

See Also
       at(1), cron(8), mail(1)

																       calendar(1)
All times are GMT -4. The time now is 05:11 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy