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

ref: 2b467c818c691e6c743c2e147522f97443d4ba3c unix-shell-programming-revised-edition-programs/add -rw-r--r-- 458 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
27
28
29
30
31
32
33
#!/bin/sh

#
# Add someone into the phonebook
#

echo "Type in your new entry."
echo "When you are done, just type a single"
echo "RETURN on the line."
first=
entry=

while true
do
  echo -n ">> "
  read line

  if [ -n "$line" ]
  then
    entry="$entry$line^"

    if [ -z "$first" ]
    then
      first=$line
    fi
  else
    break
  fi
done
echo "$entry" >> $PHONEBOOK
sort -o $PHONEBOOK $PHONEBOOK
echo
echo "$first has been added to the phone book."