이 코드에서 excludespec
변수는 부분 문자열과 모두 일치 할 것으로 예상되지만 정확한 표현을 사용하는 tar 명령을 전달하는 대신 실제 실행 파일과 일치하는 실제 파일을 평가하는 것처럼 보입니다.bash 스크립트는 어떻게 파일 glob을 확장합니까?
excludespec=${PWD##*/}\_$USER\_`hostname`.bkcd_backup*
최종 결과는 아카이브가 제외 목록과 일치하지 않는 생성되는 그래서 타르 출력 :
tar: .: file changed as we read it
그것이 내가 모르는 무언가를 정의하는 문자열인가?
#!/bin/sh
# bkcd - backup current directory in situ
DMY_M() {
date +%Y%m%d_%H%M
}
timestring=$(DMY_M)
echo `pwd` - $timestring > .bkcdspec
filename=${PWD##*/}\_$USER\_`hostname`.bkcd_backup.$timestring.tar.gz
excludespec=${PWD##*/}\_$USER\_`hostname`.bkcd_backup*
fullexclude="$excludespec"tar.gz
echo excludespec - $excludespec
echo filename - $filename
echo fullexclude - $fullexclude
tar -cpzf $filename --exclude=$fullexclude .
rm .bkcdspec
당신은 할 필요가 없습니다 [같은 질문을 두 번 (http://superuser.com/q/539173/4714) –