#!/bin/sh ## Simple Bourne shell script example, ## works with sh, ksh, bash, zsh, etc. ## ## Multi line print one with " the other with ' ## echo "Hallo $USER, nice to meet you. It is `date` here :) " echo 'Hallo $USER, nice to meet you. It is `date` here :) ' ## ## Assign command line arguments ## prg="$0" foo="$1" bar="$2" baz="$3" num_args=$# ## or ## ## If/then/elsif/fi ## if [ "$num_args" = 1 ]; then echo "one arg given" elif [ "$num_args" -gt 2 ]; then echo "more than two arg" else echo "Zero or two args given (well, they are $num_args) " fi ## ## Case statement ## case "$foo" in hello|hi|hello) echo Greetings to you too ;; *) echo "I don't know what you mean with '$foo'" ;; esac ## ## Loop over (e.g., list of files) ## for f in /ftp/rosat/archive/100000/*[7-9][24]p; do echo found $f done ## ## Function definition ## show_function_args () { echo "1='$1'" echo "2='$2'" echo ... or } show_function_args one "two - zwei" show_function_args one two - zwei echo "__END__ :)"