The test command can be used to compare two integers, to test if a file exists or is readable, to determine if two strings are equal, or to test several other conditions. The test command is often used with the flow-control constructs described above. A complete list of test operators can be found in the man page for test . Each time a program is executed from within a shell script, a value is returned to indicate whether the program ran successfully or not. In most cases, a value of zero is returned on successful execution, and a nonzero number is returned if the program encountered an error.
Some signals cause shell scripts to terminate.
Sometimes a shell script will need to do some cleanup, such as deleting temporary files, before exiting. The trap command can be used either to ignore signals or to catch them to perform special processing. A useful capability in shell programming is to assign the output from a program to a shell variable or use it as a pattern in another command. Each is compiled and executed. Then these files are deleted.