home | O'Reilly's CD bookshelfs | FreeBSD | Linux | Cisco | Cisco Exam  


18.4 Exercise

See Appendix A, Exercise Answers for the answer.

  1. Convert the following shell script into a Perl program:

    cat /etc/passwd |
    awk -F: '{print $1, $6}' |
    while read user home
    do
      newsrc="$home/.newsrc"
      if [ -r $newsrc ]
      then
        if grep -s '^comp\.lang\.perl\.announce:' $newsrc
        then
          echo -n "$user is a good person, ";
          echo "and reads comp.lang.perl.announce!"
        fi
      fi
    done