HacksLinux SysAdmin Notes
The following article describes the basic syntax and includes a simple example of the BASH CASE statement usage.
The CASE statement is the simplest form of the IF-THEN-ELSE statement in BASH.
Sometimes, we need to check if the pattern presents in a file and take some actions depending on the result.
It can be done with the help of 'exit status codes'. Each Linux command returns a status when it terminates normally or abnormally
You can use command exit status in the shell script to display an error message or perform some sort of action.
While creating BASH Scripts, it is commonly helpful to check if a file exists before attempting to perform some action.
This is a job for test command (the same as ). This command allows you to do various tests, and sets its 'exit code' to 0 (TRUE) or 1 (FALSE), whenever a test succeeds or not.
Copyright © 2011-2017 Shell Hacks - Linux Howtos and Tutorials