Thursday, 31 December 2015

Bash - basic script for requesting input from the user

As mentioned in this post, my know-how of Bash scripting is pretty nil so I've been skimming through this guide the last few days to get to grips with the basic concepts. I've put together this basic script as a reminder to myself for future reference of how to request and parse input from the user:


echo "Enter the word that you'd like to add to the dictionary and then press [Enter]."

read WORD


if [ $COUNT -gt 0 ]
then echo "Word is already contained in the dictionary."; exit;

echo "\$COUNT = $COUNT"

echo "Adding $WORD to the dictionary..."


echo "Done"

No comments: