![]() | An Overview Shell scripts generally exist to automate repetitive tasks. You are already familiar with two simple shell scripts that execute automatically each time you log on to the system. These scripts -- .profile and .kshrc - define a customized "look and file" for your environment. Both of these files simply execute a set of commands for you so that you don't have to enter them manually each time you log on. Here is a slightly more complex example. This is a simple shell script - named simple -- that prints a copy of the contents of your present working directory to a file named list.out and gives it a title heading in the first line: #!/usr/bin/ksh # simple - prints a copy of your pwd to a file print "A listing of $PWD" > list.out ls -l >> list.out exit Type the contents of the script above, name the file simple, and you have a shell script. Executing the script from the command line is as straightforward as typing the script name, provided you keep in mind the rules of execution covered in the next section. |
| * You are viewing a page from LiveFire Labs' sample online UNIX training course. Click here if you do not see a blue and green frame around this page, or view the detailed description for this course. LiveFire Labs - Online UNIX Training |