After adding the -m option, add a -s option to specify that the mail message is only to be sent if there's one and only one match to the search query.

What will be an ideal response?


A half-dozen more lines added to the code block for #1. Here's one solution:
# if the user specifies -m addr then email the result of the lookup to
# the specified recipient

if [ "$1" = "-m" ] ; then
recipient="$2"
shift 2
if [ -z "$recipient" ] ; then
echo "Error: -m requires an email recipient address"
exit 1
fi

if [ "$1" = "-s" ] ; then # only email if a single match
matches="$(grep -i "$@" $PHONEBOOK | wc -l | sed 's/[^0-9]//g')"
if [ $matches -ne 1 ] ; then
echo "Error: $matches matches to your pattern. No mail sent."
exit 1
fi
shift
fi
$lu "$@" | mail -s "rolo output" $recipient
exit 0
fi

Computer Science & Information Technology

You might also like to view...

The only calculations that are performed using the LINQ aggregate methods are Average and Count.

Answer the following statement true (T) or false (F)

Computer Science & Information Technology

Analyze the following code:

``` public class Test { public static void main(String[] args) { String s = new String("Welcome to Java"); Object o = s; String d = (String)o; } } ``` a. When assigning s to o in Object o = s, a new object is created. b. When casting o to s in String d = (String)o, a new object is created. c. When casting o to s in String d = (String)o, the contents of o is changed. d. s, o, and d reference the same String object.

Computer Science & Information Technology

On the HOME tab, in the Styles group, click ________ to display the Styles gallery

Fill in the blank(s) with correct word

Computer Science & Information Technology

Compute the grade point average (GPA) for a beginning student who has completed only the following courses:

![14942|327x98](upload://b9OErW6WPN6SOkfQgdb2a22xRsH.jpeg)

Computer Science & Information Technology