There are many times in a shell script when you want to repeatedly execute a statement or group of statements until some specified condition occurs. In addition, you might want to execute a group of statements for each element in a certain list. The shell provides three looping constructs for these situations: the for, while, […]
Shell Scripting
How to use variables in shell scripts
A variable is simply a placeholder for some value. The value can change; however, the variable name will always be the same. Shell variables are capitalized by convention. The shell maintains two lists of variables: 1. Those local to the current shell 2. Those global to all shells (environment variables). Use the set and env […]
How to debug shell scripts
When a script does not work properly, we need to determine the location of the problem. The UNIX/Linux shells provide a debugging mode. Run the entire script in debug mode or just a portion of the script. To run an entire script in debug mode, add -x after the #!/bin/[shell] on the first line: For […]