Created
August 15, 2013 08:27
-
-
Save gb-swatanabe/6239224 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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