Advertisement
solidsnake

OS Address Book Exercise

Jan 26th, 2014
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.18 KB | None | 0 0
  1. #Author - MR
  2. #Date - 1/24/14
  3.  
  4. echo "Rosales,Clifford,123456,crosales@guidon.com" | sed 's/,/ ~~~ /g' > addressbook
  5. echo "Hizon,Joseph,654321,jhizon@batak.com" | sed 's/,/ ~~~ /g' >> addressbook
  6. echo "Raymundo,Miguel,789012,mraymundo@gmail.com" | sed 's/,/ ~~~ /g' >>addressbook
  7.  
  8. until [ "$choice" == "4" ] #watch out for rookie mistakes
  9.     do
  10.         echo "======================"
  11.         echo "What do?"
  12.         echo "======================"
  13.         echo "1. Add new record"
  14.         echo "2. Display all records"
  15.         echo "3. Search"
  16.         echo "4. Exit"
  17.         echo "======================"
  18.         echo -n "Choice: "
  19.         read choice
  20.         echo
  21.        
  22.         if [ "$choice" == "1" ] #string -> "$x" == "y" --- int -> $x -eq y
  23.         then
  24.             echo -n "Enter last name: "
  25.             read last
  26.             echo -n "Enter first name: "
  27.             read first
  28.             echo -n "Enter contact number: "
  29.             read number
  30.             echo -n "Enter email address: "
  31.             read email
  32.             echo "$last,$first,$number,$email" | sed 's/,/ ~~~ /g' >> addressbook
  33.             echo
  34.             echo "~~~RECORD SUCCESSFULLY ADDED.~~~"
  35.             echo
  36.         elif [ "$choice" == "2" ]
  37.         then
  38.             cat addressbook
  39.             echo
  40.         #elif [ "$choice" == "3" ]
  41.         #then
  42.         #   echo -n "Entery query: "
  43.         #   read query
  44.         #   echo "$query*"
  45.         fi
  46.     done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement