LDP/LDP/guide/docbook/abs-guide/ex71b.sh

35 lines
871 B
Bash
Raw Normal View History

2001-07-10 14:25:50 +00:00
#!/bin/bash
2001-09-04 13:27:31 +00:00
# Another 'cat' here document, using parameter substitution.
2001-07-10 14:25:50 +00:00
2008-11-23 22:43:47 +00:00
# Try it with no command-line parameters, ./scriptname
# Try it with one command-line parameter, ./scriptname Mortimer
# Try it with one two-word quoted command-line parameter,
2001-09-04 13:27:31 +00:00
# ./scriptname "Mortimer Jones"
2001-07-10 14:25:50 +00:00
2008-11-23 22:43:47 +00:00
CMDLINEPARAM=1 # Expect at least command-line parameter.
2001-07-10 14:25:50 +00:00
if [ $# -ge $CMDLINEPARAM ]
then
2008-11-23 22:43:47 +00:00
NAME=$1 # If more than one command-line param,
2005-06-05 14:39:50 +00:00
#+ then just take the first.
2001-07-10 14:25:50 +00:00
else
2008-11-23 22:43:47 +00:00
NAME="John Doe" # Default, if no command-line parameter.
2001-07-10 14:25:50 +00:00
fi
RESPONDENT="the author of this fine script"
cat <<Endofmessage
Hello, there, $NAME.
Greetings to you, $NAME, from $RESPONDENT.
# This comment shows up in the output (why?).
Endofmessage
# Note that the blank lines show up in the output.
2008-11-23 22:43:47 +00:00
# So does the comment.
2001-07-10 14:25:50 +00:00
2008-11-23 22:43:47 +00:00
exit