View difference between Paste ID: kXztKwhZ and epDWrf7K
SHOW: | | - or go back to the newest paste.
1
#Author - MR
2-
#Date - 1/24/14
2+
#Date modified - 1/28/14
3
4-
echo "Rosales,Clifford,123456,[email protected]" | sed 's/,/ ~~~ /g' > addressbook
4+
echo "Rosales,Clifford,123456,[email protected]" > addressbook
5-
echo "Hizon,Joseph,654321,[email protected]" | sed 's/,/ ~~~ /g' >> addressbook
5+
echo "Hizon,Joseph,654321,[email protected]" >> addressbook
6-
echo "Raymundo,Miguel,789012,[email protected]" | sed 's/,/ ~~~ /g' >>addressbook
6+
echo "Raymundo,Miguel,789012,[email protected]" >>addressbook
7
8
until [ "$choice" == "4" ] #watch out for rookie mistakes
9
	do 
10
		echo "======================"
11-
		echo "What do?"
11+
		echo "What do you want to 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.~~~"
34+
			echo "~~~RECORD SUCCESSFULLY ADDED~~~"
35
			echo
36
37
		elif [ "$choice" == "2" ]
38-
			cat addressbook
38+
39
			cat addressbook | sed 's/,/ /g' | awk '{printf "%-15s%-15s%-15s%-15s\n",$1,$2,$3,$4}'
40-
		#elif [ "$choice" == "3" ]
40+
41-
		#then
41+
42-
		#	echo -n "Entery query: "
42+
		elif [ "$choice" == "3" ]
43-
		#	read query
43+
44-
		#	echo "$query*"
44+
			echo -n "Entery query: "
45
			read query
46
			echo
47
			echo "SEARCH RESULTS:"
48
			echo
49
			cat addressbook | grep -i $query
50
			echo
51
52
		else 
53
			echo “INVALID CHOICE”
54
			echo
55
		fi
56
	done