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 - 陈述和回答,所以我正在关闭这个变体。 –