user258367
user258367

Reputation: 3407

tar blocksize message

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  

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.

Upvotes: 1

Views: 2769

Answers (1)

Craig
Craig

Reputation: 165

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

Upvotes: 1

Related Questions