Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/ant/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Unix tar块大小消息_Unix_Tar - Fatal编程技术网

Unix tar块大小消息

Unix tar块大小消息,unix,tar,Unix,Tar,我正在写一个解压文件的程序。执行untartar命令时发出消息 $ tar -xf testing_Download.txt1.tar Tar: blocksize = 12 我在下面试过了 $ tar 2>&1 1>/dev/null -xf testing_Download.txt1.tar Tar: blocksize = 12 下面是磁盘中不存在的tar文件的命令输出 tar 2>&1 1>/dev/null -xf test

我正在写一个解压文件的程序。执行
untar
tar命令时发出消息

$ tar -xf testing_Download.txt1.tar  
Tar: blocksize = 12  
我在下面试过了

$ tar 2>&1 1>/dev/null -xf testing_Download.txt1.tar  
Tar: blocksize = 12   
下面是磁盘中不存在的tar文件的命令输出

tar 2>&1 1>/dev/null -xf testing_Download.txt12.tar  
tar:无法打开testing_Download.txt12.tar


我想知道如何调整tar命令,以便识别
untar
已成功执行。

使用tar的返回值

tar -xf testing_Download.txt1.tar &>/dev/null
if [ "$?" = "0" ];
then
    echo "success..."
fi
或者先检查文件是否存在:

if [ -e testing_Download.txt1.tar ];
then
    tar -xf testing_Download.txt1.tar &>/dev/null
else
    echo "tar file not there"
fi

使用tar的返回值

tar -xf testing_Download.txt1.tar &>/dev/null
if [ "$?" = "0" ];
then
    echo "success..."
fi
或者先检查文件是否存在:

if [ -e testing_Download.txt1.tar ];
then
    tar -xf testing_Download.txt1.tar &>/dev/null
else
    echo "tar file not there"
fi

但这是用来检查文件不存在的。我不确定,但可能还有其他一些情况下tar会失败。在这种情况下,返回代码是否也有帮助?因为第二种情况不适用于此。但这是用于检查文件是否不存在。我不确定,但可能还有其他一些情况下tar会失败。在这种情况下,返回代码是否也有帮助?因为第二种情况不适用于此。