[prev] [index] [next]

Shell Scripts (cont)

The next simplest shell program: "Hello, YourName"

#!/bin/sh

echo -n "Enter your name: "
read name
echo Hello, $name

Shell variables:

$ read x     # read a value into variable x
$ y=John     # assign a value to variable y
$ echo $x    # display the value of variable x
$ z="$y $y"  # assign two copies of y to variable z

Note: spaces matter ... do not put spaces around the = symbol.