Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save gb-swatanabe/6239224 to your computer and use it in GitHub Desktop.
Save gb-swatanabe/6239224 to your computer and use it in GitHub Desktop.
#!/bin/sh
# fb - file backup with timestamp and sequensal numbers
# usage : $0 filename [filename [...]]
today=`date '+%Y%m%d'`
for fn in $*
do
seq=''
# file name conflict check
while [ -e "${fn}.${today}${seq}" ]
do
seq=`expr ${seq:-0} - 1`
done
/bin/cp -aiv $fn "${fn}.${today}${seq}"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment