$Id: bash.txt 1883 2008-07-20 23:13:32Z mjs $

bash tips/tricks/HOWTOs

HOWTO: Read exit status

You can just do things like:

 if cp $1 $2 ; then
   echo succeeded
 else
   echo failed
 fi

Alternatively, $? holds the exit status of the most recently executed command.

TIP: Command substitution

`command`

or

$(command)

TIP: Redirection

To redirect stdout to /dev/null, and stderr to the tty:

$ tidy index.html 2>/dev/stdout 1>/dev/null

TIP: Parameter expansion

${foo}

or

$foo