This shell script and shell programming site aims to provide book reviews and free ebook on bash shell, korn shell, shell commands, linux shell, awk shell, unix commands, ftp shell and all other shells.

UNIX shell scripting with sh/ksh

© Dartmouth College
  • Learn what kinds of problems are suited to shell scripts
  • Review the most commonly used Unix commands that are useful in shell scripts.
  • Write simple shell scripts using the Bourne, Korn or Bash shells These notes are intended for use in a 2-part class, total duration 3 hours.

What is a Shell Script

  • A text file containing commands which could have been typed directly into the shell.
  • The shell itself has limited capabilities -- the power comes from using it as a "glue" language to combine the standard Unix utilities, and custom software, to produce a tool more useful than the component parts alone.
  • Any shell can be used for writing a shell script. To allow for this, the first line of every script is:#!/path/to/shell (e.g. #!/bin/ksh). #! The #! characters tell the system to locate the following pathname, start it up and feed it the rest of the file as input. Any program which can read commands from a file can be started up this way, as long as it recognizes the # comment convention. The program is started, and then the script file is given to it as an argument. Because of this, the script must be readable as well as executable. Examples are perl, awk, tcl and python.
  • Any file can be used as input to a shell by using the syntax:ksh myscript
  • If the file is made executable using chmod, it becomes a new command and available for use (subject to the usual $PATH search).chmod +x myscript A shell script can be as simple as a sequence of commands that you type regularly. By putting them into a script, you reduce them to a single command.

Click to Read More

Followers