 | Level: Intermediate Michael Stutz (stutz@dsl.org), Author, Consultant
20 Feb 2007 When writing a shell program, you often come across some special situation that you'd like to handle automatically. This tutorial includes examples of such situations from small Bourne shell scripts. These situations include base conversion from one string to another (decimal to hex, hex to decimal, decimal to octal, and so on), reading the keyboard while in a piped loop, subshell execution, inline input, executing a command once for each file in a directory, and multiple ways to construct a continuous loop. Part 4 of this series wraps up with a collection of shell one-liners that perform useful functions.
In this tutorial
- Shell command execution
- Shell arithmetic and base conversion
- Inline input
- Subshell execution
- Continuous loops
- Reading keyboard input
- Putting it all together
Objectives
The objective of this tutorial is to show new users how to use and implement many of the shell's methods for providing automation at various levels. It demonstrates these methods by giving tricks and tips for special situations, and it also presents a rundown of useful shell one-liners for common tasks.
Prerequisites
This tutorial is written for users who are relatively new to UNIX®. The only prerequisites are basic knowledge of the UNIX file system and the commands to manipulate it, the command line itself, and editing text files with an editor, such as vi. All of these concepts are fully described in the previous tutorials of this series.
System requirements
You need user-level access to a UNIX system with a Bourne-compatible shell environment, such as the popular bash shell. This is the only system requirement for this tutorial.
Duration
2 hours
Formats html, pdf
|  | |  |