1.Getting Input from a File
Problem: you want your shell command to read data from a file.
Solution: Use input redirection,indicated by the < character,to read data from a file.
2.keeping Your Data with Your Script
Problem: you need input to your script,but don't want a separate file.
Solution: Use a here-document,whith the << characters,redirecting the text from the command line rather than from a file.
3.Preventing Weird Behaviour in a Here-Document
Problem: Your here-document is behaving weirdly.You tried to maintain a simple list of donors using the method described previously for phone numbers.
Solution: Turn off the shell scripting features inside the here-document by escaping any or all of the characters in the ending marker.
4.Indenting Here-Documents
Problem: The here-document is great,but it's messing up your shell script's formatting.You want to be able to indent for readability.
Solution: Use <<- and then you can use tab character(only!) at the beginning of lines to indent this portion of your shell script.
5.Getting User Input
Problem: You need to get input from the user.
Solution: Use the read statement read or read -p "answer me this " ANSWER or read PRE MID POST
6.Getting Yes or No Input
Problem: You need to get simple yes or no input from the user,and you want to be as user-friendly as possible.In particular,you do not want to be case sensitive,and you want to provide a useful default if the user presses the Enter key.
Solution: use this self-contained function.
7.Selecting from a List of Options
Problem: You need to provide the user with a list of options to choose from and you don't want to make them type any more than necessary.
Solution: use bash's built-in select construct to generate a menu,then have the user choose by typing the number of the selection
8.Prompting for a Password
Problem: You need to prompt the user for a password,but you don't want it echoed on the screen.
Solution: read -s -p "password: " PASSWD
printf "%b" "\n"