pwd
/home/pjw/study/bash/simpleCopy
vi copy.sh
Bash
복사
copy.sh
#!/bin/bash
now=`(date +"%Y%m%d")`
cp -Rp $1 $1_$now
echo "Successfully backed up "'"'$1_$now'"'" with the "'"'$1'"'
Bash
복사
./copy.sh /home/pjw/test/b.txt
Successfully backed up "/home/pjw/test/b.txt_20200117" with the "/home/pjw/test/b.txt"
cat /home/pjw/test/b.txt
test file
cat /home/pjw/test/b.txt_20200117
test file
ls -trl /home/pjw/test/
합계 8
-rw-r--r-- 1 root root 0 1월 17 14:56 a.txt
-rw-r--r-- 1 root root 0 1월 17 14:56 a.txt_20200117
-rw-r--r-- 1 root root 10 1월 17 14:57 b.txt
-rw-r--r-- 1 root root 10 1월 17 14:57 b.txt_20200117
Bash
복사