You can use the return value of 'tar'.
The following code is from a Perl script that performs this type of error check:
$state = `tar -zcvf ./$name.tgz $dir > ./$name.log 2>&1`;
if (! $state) { `cp ./$name.tgz $target`; }
else { printf ("Warning: tar returned error code %d!\n", $state); }
Just adapt that to the 'bash' syntax.


Reply With Quote

Bookmarks