내 bash 스크립트에 어떤 문제가 있나요? [폐쇄]

내 bash 스크립트에 어떤 문제가 있나요? [폐쇄]

내 스크립트에 어떤 문제가 있는지 파악하는 데 어려움을 겪고 있습니다.

#!/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

관련 정보