[bash] Check if variable is set or blank

Hello guys.
In my script, i have the following code:

echo "The tarfile contains these directorys"
tar -tf file.tar > tarlist.txt
cat tarlist | awk -F/ '{print $1 "/" $2}' | nl
echo "Enter path of the directory you want to extract or just press enter to extract everything: "
read path
/usr/local/bin/gtar -xf file.tar $path

I need to check if the user gave a path to the script, or if he just pressed enter?
I know what to do between the 'THEN' and 'ELSE' statements.
I just need to know how to check if $path is really set or not.

case $path in '') echo not set;; *) echo is set;; esac

If you want to distinguish between not set and set but empty, have a look at the ${var-value} and ${var:-value} construct.

As long as you are not quoting $path, you don't need to make things conditional, though.. Your code should work already. (On the other hand, you properly ought to put $path in double quotes.)

PS. You are extracting into tarlist.txt, but using tarlist without the .txt. Also the cat | awk is a Useless Use of Cat. Google for that phrase.