2
我有一個腳本,用於檢查文件是否存在於tar文件中,但是由於它總是轉到腳本的「其他」部分,所以出現錯誤。我非常肯定它不應該那樣。使用tar和grep命令檢查tar文件裏面是否存在文件
日期爲「Mon dd」格式(1月11日)。
echo "enter date: \c"
read date
tarfile=`tar -tvf tarfile.tar | grep some_file | grep "$date"`
if [ -f "$tarfile" ]; then
echo "yes"
else
echo "no"
fi
謝謝。
這個問題似乎是題外話,因爲也有人在這裏問:http://unix.stackexchange.com/questions/97068/tar-and-if - 陳述和回答,所以我正在關閉這個變體。 –