|
|||
Department of Engineering | |
University of Cambridge > Engineering Department > computing help |
Various text-based shells are in use. sh, the Bourne Shell, is the oldest. The C-shell (csh) has many useful features lacking from sh but isn't that good for programming in. The Korn Shell (ksh) and the (very similar) POSIX shell are developments of sh that incorporates many csh features. bash is similar and is freely available (it's the default on linux and MacOS X). This document is aimed at bash users on CUED's Teaching System, though non-csh users elsewhere shouldn't have any problems.
Writing a shell script is easy - start up your editor with a file called try then type a few harmless commands into this file, one per line. For example
hostname date ls
then save it as text. You want to make this file executable, so in the terminal window type `chmod u+x try', adding eXecute permission for the User. Run this script by typing its name (on some systems you may need to type `./try' - the '.' is shorthand for 'the current directory'). You should see the machine's name, the date and a list of files.
Even scripts as simple as this can save on repetitive typing, but much more can be easily achieved.