Bourne Shell Scripting/Test Program

From Wikibooks, the open-content textbooks collection

Jump to: navigation, search
#!/bin/sh

echo "Hello World!"

The above is by far the simplest script we've seen. Programmers everywhere will recognise this as a typical "Hello World" type program, just so you can see that the Bourne shell actually will do what you tell it to do. The next example is a bit more interesting:

#!/bin/sh

date +"You are logged in at $HOSTNAME, as $USER. It is %c"

If you run the above script you should get a single line of output like this:

 You are logged in at joes-notebook.local, as joe. It is Sun May 25 15:50:42 2008