답변:
존재 여부를 확인할 필요가 없으며 읽기 및 쓰기 권한 검사로 충분합니다.
에서 help test관련 테스트 선택 :
-a FILE True if file exists.
-e FILE True if file exists.
-f FILE True if file exists and is a regular file.
-r FILE True if file is readable by you.
-s FILE True if file exists and is not empty.
-w FILE True if the file is writable by you.
그래서 당신은 시도 할 수 있습니다 :
FILE="/path/to/some/file"
if [[ -r $FILE && -w $FILE ]]
then
# do stuff
else
# file is either not readable or writable or both
fi
if [[ -r $FILE ]] && [[ -w $FILE ]]대신 해서는 안 if [[ -r $FILE && -w $FILE ]]됩니까?
-r하고-w사업자