16.05.2015 Views

Working with the Unix OS

Working with the Unix OS

Working with the Unix OS

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

<strong>Unix</strong> Tools<br />

grep "$name" $PHONEBOOK > /tmp/matches$$<br />

if [ ! -s /tmp/matches$$ ]; <strong>the</strong>n<br />

echo "Can't find $name in <strong>the</strong> phone book"<br />

else<br />

# display each matching entry<br />

while read line; do<br />

./rolodisplay "$line"<br />

done < /tmp/matches$$<br />

fi<br />

rm /tmp/matches$$<br />

#!/bin/sh<br />

# @(#) rolodisplay - display rolo entry from phone book<br />

# ------------------------------------------<br />

# | Joe's Pizza |<br />

# | George Street |<br />

# | Brisbane |<br />

# | 864-3021 |<br />

# | |<br />

# | |<br />

# | o o |<br />

# ------------------------------------------<br />

echo<br />

echo "------------------------------------------"<br />

entry=$1<br />

IFS=":"<br />

set $entry<br />

# field separater<br />

for line in "$1" "$2" "$3" "$4" "$5" "$6"<br />

do<br />

echo " |\r| $line"<br />

# draws right side first \r sends cursor back to beginning<br />

done<br />

echo "| o o |"<br />

echo "------------------------------------------"<br />

echo<br />

#!/bin/sh<br />

# @(#)roloadd - add someone to <strong>the</strong> phone book<br />

echo "Type in your new entry"<br />

echo "enter a single RETURN when done"<br />

first=<br />

entry=<br />

while true ; do<br />

echo ">> \c"<br />

read line<br />

if [ -n "$line" ]; <strong>the</strong>n<br />

entry="$entry$line:"<br />

if [ -z "$first" ]; <strong>the</strong>n<br />

first=$line<br />

fi<br />

else<br />

break<br />

fi<br />

done<br />

echo "$entry" >> $PHONEBOOK<br />

42

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!