Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

a simple script

Status
Not open for further replies.

props

Technical User
Nov 22, 2003
17
GB
any idea how to make this to work . User inputs a filename and cat command reads the filename


:
# simple cat commands

echo "\n COMMAND MENU\n"
echo " a.read a file"
echo " b. exit"

echo "Enter a, or b: \c"
read answer
echo
case "$answer" in
a)
cat $answer
;;
b)
kill
;;
*)
echo "There is no selection: $answer"
;;
esac
echo
 
You need another read in the a) case statement to capture the name of the file to feed to cat (!)
 
Remove the ">>" from the example below, they are just to hi-light the changes.


# simple cat commands

echo "\n COMMAND MENU\n"
echo " a.read a file"
echo " b. exit"

echo "Enter a, or b: \c"
read answer
case "$answer" in
a)
>>echo "Enter path & filename \c"
>>read FILENAME
>>cat $FILENAME |pg #or pg $FILENAME
;;
b)
>>exit 0
;;
*)
echo "There is no selection: $answer"
;;
esac
echo
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top