Hello all,

Essentially a newbie to shell scripting (and Unix/Linux as a whole!) Essentially doing this project for my year in work placement. Essentially it is a script which searches for specific files and backs them up to tape. However I need to modify said script so it can verify that it has all the files that it needs before writing to tape.

However before I can do that I need to go and write an if loop that includes a command line argument so I can run the script in test mode and prevent it to write to tape so I can test the file checking feature.

Now I'm in sixes and sevens in trying to work out how to get this loop to work. I'll post the actual loop in code at first but if you need the entire code I'll have to do some er *alterations* (hush hush you see):

if [ $# -test 0 ]; then
echo @skipping tape dump - diagnostic test mode@
tar tf $tapedevice

Now whenever I save that and try and excecute it, it comes up with...

./test5.sh: line 27 [: -test: binary operator expected

It then goes straight to trying to back up to tape. On this machine however there is no tape drive so it can't find it so it collapses xD

Can anyone help me?

Thanks for the hint! :)

Sorry I should have worded my original post differently after I saw the guidelines for posting. I don't really want the answer just hints and tips for a budding beginner :)

Thanks again. If I succeed or fail I'll let you chaps know.

This article has been dead for over six months. Start a new discussion instead.