![내 bash 스크립트에 어떤 문제가 있나요? [폐쇄]](https://linux55.com/image/115157/%EB%82%B4%20bash%20%EC%8A%A4%ED%81%AC%EB%A6%BD%ED%8A%B8%EC%97%90%20%EC%96%B4%EB%96%A4%20%EB%AC%B8%EC%A0%9C%EA%B0%80%20%EC%9E%88%EB%82%98%EC%9A%94%3F%20%5B%ED%8F%90%EC%87%84%5D.png)
내 스크립트에 어떤 문제가 있는지 파악하는 데 어려움을 겪고 있습니다.
#!/bin/bash
echo "Good Day $USER"
if [ -f "$1" ]
then
tar -cvf home-10-07-2017.tar --files-from /dev/null
echo "You are about to back up the following files… $*"
for i in "$@"
do
if [ -f "$i" ]
then
PROCEED='YES'
else
PROCEED='NO'
fi
if [ $PROCEED='YES' ]
then
tar -rvf home-10-07-2017.tar "$i"
fi
done
tar -vzf home-10-07-2017.tar.gz
else
echo 'You did not enter any files to backup'
fi
스크립트를 실행하면 다음 오류가 발생합니다.
./backups.sh first.txt second.txt
Good Day fed
You are about to back up the following files… first.txt second.txt
first.txt
second.txt
tar: You must specify one of the '-Acdtrux', '--delete' or '--test-label' options
답변1
마지막 줄의 실제 오류 tar
(내 생각에 이것이 주요 문제인 것 같습니다)는 실제로 수행할 작업을 지정하지 않았기 때문입니다. 사양 f
뒤에는 파일 이름이 옵니다. v
무엇을 해야할지 자세히 말하십시오 . 파일이 압축되었음을 나타냅니다 ( z
대부분의 버전에서 tar
중복됨 ).
당신이 원하는 작업은 t
파일 목록입니다. 이 경우 다음이 필요합니다.
tar -tvzf home-10-07-2017.tar.gz