~johanvandegriff/unix-shell-programming-revised-edition-programs

ref: 2b467c818c691e6c743c2e147522f97443d4ba3c unix-shell-programming-revised-edition-programs/lu -rw-r--r-- 445 bytes
2b467c81Johan Vandegriff added license 1 year, 8 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#!/bin/sh

#
# Look someone up on the phonebook
#

name=$1

grep $name $PHONEBOOK >/tmp/matches$$

    if [  ! -s /tmp/matches$$ ]
    then
        if [ "$name" = "^" ]
        then
          echo "Your phone book is empty."
        else
          echo "I cannot find $name in the phone book."
        fi
    else
      while read line
      do
        . ~/programs/phonebook/display "$line"
      done </tmp/matches$$
    fi

rm /tmp/matches$$