[nflug] bash scripting question

Darin Perusich Darin.Perusich at cognigencorp.com
Tue Jul 8 08:29:12 EDT 2008


When testing conditions in bash you might may want to use the extended 
test command [[...]] which allow the use of conditional operators like 
&&, ||, <, and >.

Additionally when you "exit", setting an exit status other then the 
default of 1 might prove useful if this script was called from another. 
You could test the exit value, $? and depending on the value do 
something else.

Daniel Magnuszewski wrote:
> ...I forgot to include the exit logic (Plus, this is a cleaner format):
> 
> <code>
> 
> #!/bin/bash
> 
> if [ -e filename ];
> then
>         echo "Exiting Program"
>         exit
> fi
> echo "Continue Program"
> 
> </code>
> 
> -Dan


-- 
Darin Perusich
Unix Systems Administrator
Cognigen Corporation
395 Youngs Rd.
Williamsville, NY 14221
Phone: 716-633-3463
Email: darinper at cognigencorp.com


More information about the nflug mailing list