Results 1 to 3 of 3
  1. #1
    Join Date
    Mar 2007
    Posts
    3

    Unanswered: shell script for copying and adding date

    Hello everyone, can somebody help me making this script:
    To copy one file from one directory to another and to add the current date and time the copyied file??
    Thanks in advance

  2. #2
    Join Date
    May 2005
    Location
    South Africa
    Posts
    1,365
    Provided Answers: 1
    cp $onedir/$filename $anotherdir/${filename}_`date '+%Y%m%d_%H%M%S'`

  3. #3
    Join Date
    Jan 2006
    Posts
    5

    Lightbulb

    DATE=`date '+%Y%m%d_%H%M%S`
    cp $onedir/$filename $anotherdir/${filename}_${DATE}

    If the date contains any '/' then there can be problem in file creation. So, careful when using date like `date +%D`

Posting Permissions

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