public
Created

  • Download Gist
datecp.sh
Shell
1 2 3 4 5 6 7 8 9 10 11 12
#!/bin/bash
 
# This will copy a file, appending the date and time
# to the end of the file name.
#
# http://c.myl.be/8BYj
 
date_formatted=$(date +%Y-%m-%d_%H.%M%S)
file_extension=`echo "$1"|awk -F . '{print $NF}'`
file_name=`basename $1 .$file_extension`
 
cp -iv $1 $file_name-$date_formatted.$file_extension

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.