![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Create Year directory, date subdirectory and archive the file | madhunk | UNIX for Dummies Questions & Answers | 2 | 12-13-2007 11:25 AM |
| Specify a previous date as start date in shell script | ritzwan0 | Shell Programming and Scripting | 2 | 09-25-2006 05:58 PM |
| Directory create date | Bab00shka | UNIX for Dummies Questions & Answers | 2 | 06-29-2005 10:42 AM |
| create directory named current date | flowrats | UNIX for Dummies Questions & Answers | 2 | 07-30-2002 11:26 PM |
| How to find Previous date and Coming date | arunava_maity | UNIX for Dummies Questions & Answers | 2 | 05-24-2001 11:41 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
want to create directory with the previous date
I need some help to complet the below script:
DATE1=`date "+%d"` #DATE2=`expr $DATE1 - 1` #DATE3=$DATE2`date "+%m%y"` DATE4=`date "+%a"` if [ $DATE4 = Mon ]; then DATE2=`expr $DATE1 - 3` else DATE2=`expr $DATE1 - 1` fi cd /data/builds/612hf8/SAS/retail/plan_61/scripts/meserver DATE3=$DATE2`date "+%m%y"` mkdir $DATE3 echo "dir created" mv *.log $DATE3 echo "logs moved to $DATE3 folder" The above script creates the directory with the previous day date. along with the above script output, i need how to create month end directories that means 30th or 31st of date. if suppose date is 1st of any month, this script not creating directory of the previous date that is 30th or 31st. Please some body help me to complete above script. I would appreciate your help. Thanks, Sridhar. |
|
||||
|
Aha - date arithmetic.
You could set up an array with 28/29/30/31 days lookups for the months and leapyear calculations. I once wrote a C program called timecalc. Here it is, if it's of any use: All usual disclaimers, non-warranties, and so-on apply! Alternatively, you could try and make some clever use of the "cal" (calendar) program. |
|
|||||
|
you can get the previous day's date with following command:
DATE_STAMP=`TZ=CST+24 date +%y%m%d` Try the following link: Getting yesterday DATE |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|