Job control allows you to selectively stop (suspend) the execution of processes and continue their execution at a later point in time.

Testing files in scripts is easy and straight forward. This is where shell scripting starts to show its glory! In Bash you can do file testing for permissions, size, date, filetype or existence.

Integer Comparison Operators

How to compare integers or arithmetic expressions in shell scripts.

Flag Description -eq is equal to -ne is not equal to -gt is greater than -ge is greater than or equal to -lt is less than -le is less than or equal to < is less than – place within double parentheses <= is less than or equal to (same rule as previous row) > is greater than (same rule as previous row) >= is greater than or equal to (same rule as previous row)

String Comparison Operators

String comparison in Bash.

Flag Description = is equal to == same as above != is not equal to < is less than ASCII alphabetical order > is greater than ASCII alphabetical order -z string is null (i.e. zero length) -n string is not null (i.e. !zero length)

Compound Operators

Useful for boolean expressions and is similar to && and || . The compound operators work with the test command or may occur within single brackets [ <expr> ].

Flag Description -a logical and -o logical or

List Constructs

Provides a means of processing commands consecutively and in effect is able to replace complex if/then/case structures.

Construct Description && and construct || or construct

Reserved Exit Codes

Useful for debugging a script. Exit takes integer args in the range 0-255.

Exit Code No. Description 1 Catchall for general errors 2 Misuse of shell builtins 126 Command invoked cannot execute 127 Command not found 128 Invalid argument to exit 128+n Fatal error signal "n" 130 Script terminated by Control-C

Sending Control Signals

You can use these key-combinations to send signals

Key Combo Description Ctrl+C The interrupt signal, sends SIGINT to the job running in the foreground. Ctrl+Y The delayed suspend character. Causes a running process to be stopped when it attempts to read input from the terminal. Control is returned to the shell, the user can foreground, background or kill the process. Delayed suspend is only available on operating systems supporting this feature. Ctrl+Z The suspend signal, sends a SIGTSTP to a running program, thus stopping it and returning control to the shell.