« January 2008 | Main | May 2008 »

February 2008 Archives

February 28, 2008

Shell - Test for argument

I always forget this and spend ages finding out how to do it. How to test for an argument passed from the command line to a shell script, and not get "argument expected" error:

if [ -z "$1" ]; then
echo argument expected
exit 1
fi

The secret is the quotes around the $1.

About February 2008

This page contains all entries posted to numbersix in February 2008. They are listed from oldest to newest.

January 2008 is the previous archive.

May 2008 is the next archive.

Many more can be found on the main index page or by looking through the archives.

Powered by
Movable Type 3.33