开发者

tar blocksize message

开发者 https://www.devze.com 2023-02-07 06:41 出处:网络
I\'m writing a program which untars a file. While doing untar tar command give message $ tar -xf testing_Download.txt1.tar

I'm writing a program which untars a file. While doing untar tar command give message

$ tar -xf testing_Download.txt1.tar  
Tar: blocksize = 12  
开发者_如何学C

I tried below

$ tar 2>&1 1>/dev/null -xf testing_Download.txt1.tar  
Tar: blocksize = 12   

Below was command output for tar file which was not present in disk

tar 2>&1 1>/dev/null -xf testing_Download.txt12.tar  

tar: cannot open testing_Download.txt12.tar

I want to know how can I tweak my tar command so that I can identify that untar got executed successfully.


Use the return value of tar.

tar -xf testing_Download.txt1.tar &>/dev/null
if [ "$?" = "0" ];
then
    echo "success..."
fi

or check if the file is there first:

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

精彩评论

暂无评论...
验证码 换一张
取 消