Results 1 to 6 of 6

Thread: %d variable doesn't work anymore?

  1. #1
    Join Date
    Oct 2006
    Location
    Chicago, IL
    Beans
    192
    Distro
    Ubuntu 10.04 Lucid Lynx

    %d variable doesn't work anymore?

    I'm trying to do have a simple backup run daily and setup a copy script to copy into a folder by day.

    I use to use %d which would populate with the day of the month. However, now all it does is create a folder called "%d".

    I've tried to find a solution and don't see anything on why it doesn't work. Anybody help?
    Robert Stolorz
    www.RobertStolorz.com

  2. #2
    Join Date
    May 2010
    Location
    Tewkesbury uk
    Beans
    7,520
    Distro
    Ubuntu Development Release

    Re: %d variable doesn't work anymore?

    Hi

    Post your script and all other relevant information.

    You have provided way to little information to help you.

    Post details of you setup and environment as well please.

    Kind regards
    Join us on irc at #ubuntuforums. For web chat see here

    If you believe everything you read, you better not read. ~ Japanese Proverb

    Do not read newspapers on an empty stomach ~ Russian Proverb ~ BrunoLotse

  3. #3
    Join Date
    Oct 2006
    Location
    Chicago, IL
    Beans
    192
    Distro
    Ubuntu 10.04 Lucid Lynx

    Re: %d variable doesn't work anymore?

    This is the script, it works but creates a directory called "%d"

    cp -R /home/Public /BACKUP/%d

    Ubuntu 12.04 LTS x64 server
    Robert Stolorz
    www.RobertStolorz.com

  4. #4
    Join Date
    May 2010
    Location
    Tewkesbury uk
    Beans
    7,520
    Distro
    Ubuntu Development Release

    Re: %d variable doesn't work anymore?

    Hi

    Quote Originally Posted by FeraTech View Post
    This is the script, it works but creates a directory called "%d"

    cp -R /home/Public /BACKUP/%d

    Ubuntu 12.04 LTS x64 server
    It would create a directory called %d if that is what you are asking it to do.

    Code:
    matthew-S206:/home/matthew % mkdir -p BACKUP/%d
    matthew-S206:/home/matthew % ls -ld BACKUP/%d  
    drwxrwxr-x 2 matthew matthew 4096 May  4 02:02 BACKUP/%d/
    matthew-S206:/home/matthew %
    I don't see how that would have ever created a directory with the date in it.

    Are sure sure you're not trying to do something like this...

    Code:
    mkdir -p /BACKUP/$(date +"%d") && cp -R /home/Public /BACKUP/$(date %d);
    You may even want to store the day in a variable and use that in both places.

    EDIT:

    Silly question: what shell are you using ?

    Kind regards
    Last edited by matt_symes; May 4th, 2013 at 02:09 AM.
    Join us on irc at #ubuntuforums. For web chat see here

    If you believe everything you read, you better not read. ~ Japanese Proverb

    Do not read newspapers on an empty stomach ~ Russian Proverb ~ BrunoLotse

  5. #5
    Join Date
    Feb 2011
    Location
    Coquitlam, B.C. Canada
    Beans
    1,334
    Distro
    Ubuntu 12.04 Precise Pangolin

    Re: %d variable doesn't work anymore?

    Above, I thiink Matt meant to write
    Code:
    mkdir -p /BACKUP/$(date +"%d") && cp -R /home/Public /BACKUP/$(date +%d);
    Example:
    Code:
    doug@doug-64:~/test$ ls -l
    total 28
    drwxrwxr-x 2 doug doug 4096 May  3 21:37 backup
    drwxr-xr-x 3 doug doug 4096 Jul  2  2011 o1
    doug@doug-64:~/test$ ls -l backup
    total 0
    doug@doug-64:~/test$ cp -r o1 backup/$(date +%d)
    doug@doug-64:~/test$ ls -l backup
    total 4
    drwxr-xr-x 3 doug doug 4096 May  3 21:46 03
    doug@doug-64:~/test$ ls -l backup/03
    total 12
    -rw-r--r-- 1 doug doug    6 May  3 21:46 bla.txt
    drwxr-xr-x 3 doug doug 4096 May  3 21:46 t2
    -rwxr--r-- 1 doug doug  501 May  3 21:46 test
    doug@doug-64:~/test$ ls -l o1
    total 12
    -rw-r--r-- 1 doug doug    6 Jul  2  2011 bla.txt
    drwxr-xr-x 3 doug doug 4096 Jul  1  2011 t2
    -rwxr--r-- 1 doug doug  501 Jul  2  2011 test
    Any follow-up information on your issue would be appreciated. Please have the courtesy to report back.

  6. #6
    Join Date
    May 2010
    Location
    Tewkesbury uk
    Beans
    7,520
    Distro
    Ubuntu Development Release

    Re: %d variable doesn't work anymore?

    Hi

    Thanks DougS.

    3am typo that one .

    Kind regards
    Join us on irc at #ubuntuforums. For web chat see here

    If you believe everything you read, you better not read. ~ Japanese Proverb

    Do not read newspapers on an empty stomach ~ Russian Proverb ~ BrunoLotse

Tags for this Thread

Bookmarks

Posting Permissions

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