Quote:
Originally Posted by brent21090
Hi CRTS
Yes I actually meant mt -f /dev/st0 fsf 1
Question: I am not clear as to what '[[$? ==0]];' means.
|
Ok, first of all you use a "funny" sign to pass the options. It is supposed to be a '-' (minus) when specifying options. Yours was longer. I copy+pasted your text and so I had that error in the above script, too. But I corrected that now.
As for your questions:
This is not correct. The spaces are important; otherwise you will get an error. As for the meaning of
Code:
[[ $? == 0 ]]
^ ^ spaces are important
This is simply a test. The '$?' holds the exit value of the last executed command. A value of 0 usually indicates that the command succeeded. We check this value to determine if the mt command succeeded. I assume that it will set an exit status of 2 if there are no more files on the tape. See the manpage of mt for that:
So the while-loop will keep executing until mt has read the last file.
The test-condition for the loop is
This is nearly the same as '[[ $? == 0 ]]'. Thinking about it, this test should also be in double brackets '[['. They are more 'robust' then the single ones. I corrected that, too.
Quote:
what does 'if' mean at the end of the script you provided?
Thanks for your help.
|
That is NOT a mistyped 'if' but it is indeed a 'fi'. It simply indicates the end of the 'if' construct. Its c++ equivalent, e.g, would be the closing curly brace '}'.