Reputation: 10861
#!/bin/sh
tar=$1
if [ -f $tar ]
then
tar xvf $tar
else
exit 1
fi
... <more code>
I need a conformation that the tar actually happened successfully, otherwise abort the execution of the script.
The tar file extract might not go through because
tar
command$tar
Do Linux utilities have some return values? How should I use them here?
Upvotes: 1
Views: 10452
Reputation: 6016
This
tar xvf "$tar" || exit 1
or this (if you want to check if file exists yourself)
[ -f "$tar" ] && tar xvf "$tar" || exit 1
Upvotes: 3