the diary of how to backup one more files in linux

#!/usr/bin/bash

#to backup one more files

#asha 2017/4/17

if [ $# \< 1 ]

then 

echo please give at least one existed file you wanna backup

fi

date=`date +%F`

for file in $*

do

if [ ! -e $file ]

then

echo file not existed

exit

fi

if [ -e $file$date ]

then

echo are you sure to override this existed updated file?

read answer

if [ $answer != 'y' ]

then

exit

fi

else

touch $file$date

fi

done

ls $* | xargs -n1 -i cp ./{} ./{}$date

ls $* | xargs -n1 -i echo copy from ./{} to ./{}$date is done 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章