Modify lu from Chapter 6 to use printf to print the name and phone number so that they line up in columns for names up to 40 characters in length (Hint: use cut –f and the fact that the fields in the phonebook are separated by tabs).

What will be an ideal response?


# look someone up in the phone book
#

grep $1 phonebook | while read entry
do
name=$( echo "$entry" | cut -d\ -f1)
number=$( echo "$entry" | cut -d\ -f2)
printf "%-40s%s\n" "$name" $number
done

exit 0

Computer Science & Information Technology

You might also like to view...

A compound statement is enclosed between:

a. [ ] b. { } c. ( ) d. < >

Computer Science & Information Technology

Hand trace a stack X through the following operations:

``` X.push(new Integer(4)); X.push(new Integer(3)); Integer Y = X.pop(); X.push(new Integer(7)); X.push(new Integer(2)); X.push(new Integer(5)); X.push(new Integer(9)); Integer Y = X.pop(); X.push(new Integer(3)); X.push(new Integer(9)); ```

Computer Science & Information Technology

What are three dimensions of software quality?

What will be an ideal response?

Computer Science & Information Technology

To display data vertically rather than horizontally, replace the semicolon at the end of the command with ____.

A. \G B. \V C. % D. #

Computer Science & Information Technology