read user input

Sep 20th, 2011
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. $ more
  2. #!/bin/bash
  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]}:-)"
RAW Paste Data