The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #1 (permalink)  
Old 11-18-2007
sridhusha sridhusha is offline
Registered User
  
 

Join Date: Sep 2007
Posts: 16
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.