Shell Scripting

Table of Contents

Shell Scripting

Shell scripting automates repeating actions. It is reliable, used in server startup scripts in Linux. It is fast to use, simply write the same commands as you do in command line.

This article is a work in progress.


Hello world – lspwd

A sample shell script that runs ‘ls’ and ‘pwd’ one after another.

$ nano lspwd
#!/bin/bash
ls
pwd
$ chmod a+x lspwd
$ ./lspwd
foo   Examples
/home/tero/


See also

aboutusers – “for each” is the most important control structure in shell scripts.

http://tldp.org/LDP/abs/html/ Best bash scripting reference. Don’t run the first example that does something as root.

Per user bin



Posted in Old Site | Tagged , , , | 3 Comments

3 Responses to Shell Scripting

  1. To make your script available for all users,
    $ sudo cp lspwd /usr/local/bin/
    Then you can, in any directory
    $ lspwd