Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Need to go back 1 day using the date command Post 11764 by Cameron on Tuesday 11th of December 2001 11:11:28 PM
Old 12-12-2001
MySQL Solved ...

Try the following ... Smilie

## Long Name Month Listing.
lngmth="January February March April May June \
July August September October November December"
## Short Name Month Listing.
shtmth="Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec"

##
## Get Current Month Number (01-12).
xcurmth=`date +%m`
## Get Previous Month Number (01-11).
xprvmth=`expr $xcurmth - 1`
## Get Year Number (??).
xcuryr=`date +%Y`
## Get Previous Year Number (??).
xprvyr=`expr $xcuryr - 1`

xx=`echo $shtmth | cut -f$2 -d" "`
zz=`echo $lngmth | cut -f$2 -d" "`
XX=`echo $shtmth | cut -f$2 -d" "`$xprvyr
ZZ=`echo $lngmth | cut -f$2 -d" "`$xcuryr


If $xprvmth = 0 then you must use $xprvyr and 12 for the month. ...
(eg. `echo $shtmth | cut -f12 -d" "`$xprvyr)
 

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
All times are GMT -4. The time now is 09:55 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy