Shell Basics

Hacker Girl

This is post 2 of 19 in the series “[ Shell Scripting ]” Shells The programming language the shell recognizes is dependant on the shell: sh, csh, tcsh, Korn shell, bash. In some Unix environments, when users log in, the Bourne shell (or its close cousin, bash) starts up. On many systems, however, users will …

Testing in bash

This is post 3 of 19 in the series “[ Shell Scripting ]” The test Command The command used in most conditionals is the test command. test returns true or false (more accurately, exits with 0 or non-zero status) depending on whether the test is passed or failed. It works like this: test operand1 operator …

Debugging

Glenn Norman

This is post 6 of 19 in the series “[ Shell Scripting ]” There are several very elementary techniques you can use to debug your scripts. Switch Your Shell to Execute (Debug) Mode Remember the Order of Operations? You can change the mode of the Bourne/bash/Korn shell to show you what your command looks like …

Shell Variables

Linux bash shell

This is post 8 of 19 in the series “[ Shell Scripting ]” In Unix there are three kinds of variables: System Variables (you normally can’t change these), Environment Variables (which are yours, and specific to your environment) and Shell Variables (which you declare and use in programming). Bourne, bash and Korn allow you to …

IO Redirection

Hacker Girl

This is post 9 of 19 in the series “[ Shell Scripting ]” By default, every process has three associated file descriptors: standard input (0), standard output (1) and standard error (2). For these, Your keyboard is the default source of standard input. Your monitor is the default target for standard output, and Your monitor …

Pipes

Glenn Norman

This is post 10 of 19 in the series “[ Shell Scripting ]” Any number of commands can be pipelined together. command1 | command2 The above command creates a pipe: the standard output of command1 is connected to the standard input of command2. Any command that can accept Standard Input and produce Standard Output is …