Find the answer to your Linux question:
Results 1 to 2 of 2
Hi, I am a newbie to Linux. I am using RH Enterprise edition. I am writing a Script which will create folder everyday with the date as the folder name. ...
  1. #1
    Just Joined!
    Join Date
    Jan 2009
    Posts
    2

    Date wise Folder name

    Hi,

    I am a newbie to Linux. I am using RH Enterprise edition.

    I am writing a Script which will create folder everyday with the date as the folder name. For example: 20090120 or 20090119 etc. And then I will same some file in that folder, Zipped that folder and then mailed that zipped folder to some receipt's.

    But every time I create a folder there is some garbage at the end of the folder name. For example: 20010120? or 20090120??. So when I try to enter or zip that folder it is giving error such as ...... No File Found / No such Folder....etc.

    Another this is that when I run the mkdir command from command prompt it is working fine. only problem is running mkdir cmd from Script.

    my script is like that.......

    **********************
    Date=`date +%F -d '-1 day'`
    mkdir /root/xyz/$Date
    **********************

    Can any body tell me what to do..........


    Regards
    Adnan

  2. #2
    Just Joined!
    Join Date
    Apr 2006
    Location
    UK, Devon
    Posts
    40
    Hi Dude,
    I do the same sort of thing with my back ups this is what I used and works every time.

    DirDate=$(date +%d-%m-%y)

    which displays for example

    21-01-09

    then you can do your

    mkdir /root/xyz/$DirDate

    Hope this helps.

    Luke

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...