Find the answer to your Linux question:
Results 1 to 5 of 5
In AIX Unix, I can copy a file and rename to the curret date and time, in a terminal bash, like such... Code: cp file123.jpg file'date +%D%T'.jpg However, when usinf ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    May 2004
    Location
    Sharon Center, OH
    Posts
    16

    copy file, then change to date + time


    In AIX Unix, I can copy a file and rename to the curret date and time, in a terminal bash, like such...

    Code:
    cp file123.jpg file'date +%D%T'.jpg
    However, when usinf RedHat 9 flavor that I have, doesn't seem to work. Tried a bunch of solutions, and nothing. Any suggestions.

    Thanks,

  2. #2
    Linux Newbie
    Join Date
    Aug 2001
    Location
    USA, Texas
    Posts
    217
    Are you sure that you used backticks (`) and not single quotes (') ?
    [ [ SykkN alloc ] initWithThePowerTo: destroyYouAll ];
    /* Don\'t make me use it! */

  3. #3
    Linux Newbie
    Join Date
    Apr 2004
    Location
    Stockholm, Sweden
    Posts
    130
    I tried what you posted, and got an error as well.
    The problem seems to be, that the format of the date-string you try to use in the filename contains /:es

    file05/08/0418:02:25.jpg

    Which by the cp program is interpreted as well..../ such in paths.
    To have a filename that includes / in it, these need to be escaped, like this
    file05\/08\/0418:02:25.jpg

    If you can do that by formating `date`:s output I don't know, otherwise you'll have to script it I s'pose =)

    /ooop

  4. $spacer_open
    $spacer_close
  5. #4
    Linux Newbie
    Join Date
    Aug 2001
    Location
    USA, Texas
    Posts
    217
    Try the command below. (date +%Y%m%d_%H%M%S == 20040508_132005)

    Code:
    cp file123.jpg file`date +%Y%m%d_%H%M%S`.jpg
    [ [ SykkN alloc ] initWithThePowerTo: destroyYouAll ];
    /* Don\'t make me use it! */

  6. #5
    Just Joined!
    Join Date
    May 2004
    Location
    Sharon Center, OH
    Posts
    16
    Thanks for the help people, but this one was a booboo on my part. My VNC connection was not recoginzing the "`" character. So I ssh'ed in and seemd to work fine



    Thanks anyways!

Posting Permissions

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