salawank

read user input

Sep 20th, 2011
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.61 KB | None | 0 0
  1. $ more read_user_input.sh
  2. #!/bin/bash
  3.  
  4. echo -e "Hi, please type the word: \c "
  5. read  word
  6. echo "The word you entered is: $word"
  7. echo -e "Can you please enter two words? "
  8. read word1 word2
  9. echo "Here is your input: \"$word1\" \"$word2\""
  10. echo -e "How do you feel about bash scripting? "
  11. # read command now stores a reply into the default build-in variable $REPLY
  12. read
  13. echo "You said $REPLY, I'm glad to hear that! "
  14. echo -e "What are your favorite colours ? "
  15. # -a makes read command to read into an array
  16. read -a colours
  17. echo "My favorite colours are also ${colours[0]}, ${colours[1]} and ${colours[2]}:-)"
Add Comment
Please, Sign In to add comment