Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted!
- The problem statement, all variables and given/known data:
Try running 'phone4 xyz' and see what happens.
Modify your program so that if no matching name is found, an appropriate
message is displayed: "Name 'xyz' not in directory".
You could use an 'if' statement to check the value of $? to see if the grep
command was successful (remember, '0' indicates success). If the grep is
NOT successful, then echo the message (which includes the value of $name).
Give it a try.
Make sure this works with both command line arguments and with a name read
in from the user, and make sure you use the message EXACTLY as shown.
-
Relevant commands, code, scripts, algorithms:
-
The attempts at a solution (include all code and scripts):
#!/bin/bash
name=$1
if [ "$name" = "" ]
then echo -n "Name 'xyz' not in directory"
read name
fi
grep -i cheryl ~uli101/uli101/phonebook
grep -i $name ~uli101/uli101/phonebook
- Complete Name of School (University), City (State), Country, Name of Professor, and Course Number (Link to Course):
Seneca@York toronto,ontario, Canada, Joseph Hughes, ULI 101
Note: Without school/professor/course information, you will be banned if you post here! You must complete the entire template (not just parts of it).