저는 폴더 및 파일을 암호로 보호하고 압축/보관하는 (주로) 코드를 작성했습니다. 그러나이 코드는 나를 증오하는 것처럼 보입니다.Zip I/O 오류 : bash 스크립트에 해당 파일이나 디렉토리가 없습니다.
줄 단위로 실행했습니다. $file
및 $source
이 올 바르고 유효하더라도 항상 zip 명령을 실행합니다.
아이디어가 있으십니까?
다음은 소스 코드의 :
코드에서 몇 가지 문제가 있습니다#!/bin/bash
echo "Drag in the source file"
read source
echo
echo "Drag in the destination file, or press enter to select the Desktop"
read destination
echo
if [ -z "$destination" ]
then destination="$PWD/Desktop"
echo "Destination is set to the desktop"
fi
echo "Type the name of the file to make"
read file
if [ -z "$file" ]
then file="archive"
echo "File name set to archive.zip"
fi
file="${destination}/${file}"
if [ -d $"source" ]
then zip -erj "$file" "$destination"
else zip -ej "$file" "$destination"
fi
zip은 스크립트 내 경로에없는 것 같습니다. zip으로 하드 코딩하여 도움이되는지 확인하십시오. 그럴 경우 스크립트에서 경로를 설정할 수 있습니다. –
'then destination = "$ PWD/Desktop"'- 이것은 데스크탑이 아닙니다. '$ PWD'는 현재의 작업 디렉토리이며 아무것도 될 수 있습니다. 바탕 화면은'$ HOME/Desktop'입니다. 그리고 이것은'zip'이 존재하지 않는 경우 대상 디렉토리를 생성하지 않으므로 에러의 원인이 될 수 있습니다. 또한,'$ source' 대신'$ destination'을 보관하도록'zip'에 요청한 것 같습니다. – axiac
@axiac 감사합니다! 그것은 그것을 해결 한 것으로 보인다. 어쩌면 답을 만들어 해결 된 것으로 표시 할 수 있을까요? 또한, 나는 zip 구문이'zip destination source'라고 확신한다. –