Results 1 to 3 of 3

Thread: How do I set date so I know when a file was created

  1. #1
    Join Date
    Jul 2011
    Location
    Sweden
    Beans
    4
    Distro
    Ubuntu 11.04 Natty Narwhal

    How do I set date so I know when a file was created

    Hi
    I've been working with a script in ubuntu 11.04 it's basicly very simple but I got problem with a single line of code: cat /etc/passwd > passwd´date +%Y%m´
    The results I expect should be a readable file something like this example: passwd201106
    Do you know what I have done wrong or do you have a better solution?
    I'm a more used to red hat 2.0 so i wounder if it's just a minor difference between two linux systems?

  2. #2
    Join Date
    Nov 2005
    Location
    Bordeaux, France
    Beans
    11,292
    Distro
    Ubuntu 12.04 Precise Pangolin

    Re: How do I set date so I know when a file was created

    You are using the wrong kind of "apostrophes":

    Code:
    firas@itsuki ~ % cat /etc/passwd > passwd`date +%Y%m`
    firas@itsuki ~ % ls passwd*       
    passwd201107
    You can also use $(), which is less confusing:

    Code:
    firas@itsuki ~ % rm passwd201107
    firas@itsuki ~ % cat /etc/passwd > passwd$(date +%Y%m)
    firas@itsuki ~ % ls passwd*
    passwd201107
    「明後日の夕方には帰ってるからね。」


  3. #3
    Join Date
    Jul 2011
    Location
    Sweden
    Beans
    4
    Distro
    Ubuntu 11.04 Natty Narwhal

    Re: How do I set date so I know when a file was created

    Thank you Newbie mistake but i't would probably take me days to figur it out thanks once again!

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
  •