Skip to content

Instantly share code, notes, and snippets.

@myles
Created July 5, 2011 13:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save myles/1064873 to your computer and use it in GitHub Desktop.
Save myles/1064873 to your computer and use it in GitHub Desktop.
#!/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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment