home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1992 March / Source_Code_CD-ROM_Walnut_Creek_March_1992.iso / usenet / altsrcs / 1 / 1548 < prev    next >
Internet Message Format  |  1990-12-28  |  2KB

  1. From: budd@bu-it.bu.edu (Phil Budne)
  2. Newsgroups: comp.unix.wizards,alt.sources
  3. Subject: A few of my favorite pipes...
  4. Message-ID: <59915@bu.edu.bu.edu>
  5. Date: 3 Jul 90 21:25:01 GMT
  6.  
  7. A few weeks ago favorite pipes were a topic on unix-wizards.  Here are
  8. a few of my favorite pipes ( to tune of "my favoite things" ) I
  9. collected in the process of cleaning up in preparation for leaving my
  10. job;
  11.  
  12. For seeing if anything of mine is stuck in the mqueue (I call it "mq");
  13.  
  14.     #!/bin/sh
  15.     # display my items in the mail queue
  16.     if [ $# -gt 0 ]; then
  17.         who=$1
  18.     else
  19.         who=`whoami`
  20.     fi
  21.     echo Pending messages on `hostname` from user $who
  22.     #
  23.     mailq | \
  24.     awk "    BEGIN        { pr = items = found = 0; } \
  25.         /^AA/        { if( \$0 ~ /$who/ || \$0 ~ /$who\@\.\*/ ) { \
  26.                     pr = 1; found++; } \
  27.                   else { pr = 0; } items++; } \
  28.                 { if( pr ) print } \
  29.         END        { if( found > 0 ) fm = \"(\" found \" displayed)\";
  30.                   print items \" total \" fm } "
  31.  
  32. A summation of rwho output (I call it "uz");
  33.     #!/bin/sh
  34.     if tty -s <&1;
  35.     then
  36.         rwho $* | sed 's/[     ].*//' | uniq | fmt
  37.     else
  38.         rwho $* | sed 's/[     ].*//' | uniq
  39.     fi
  40.  
  41. A count of users as displayed by "uz" (I call it "uc");
  42.     rwho $* | sed 's/[     ].*//' | uniq | wc -l
  43.  
  44. For seeing what batched news is queued for a site (I call it "gq")
  45.  
  46.     #/bin/sh
  47.     # NOTE! our /usr/spool/news is in /news
  48.     SPOOLDIR=/news
  49.     if [ "$1" -a -f $SPOOLDIR/batch/$1 ]; then
  50.         sed -e 's@/[0-9].*$@@' \
  51.         -e "s@^$SPOOLDIR/@@" \
  52.         -e 's@/@.@g' < /usr/spool/news/batch/$1 |\
  53.         sort | uniq -c | sort -rn
  54.     fi
  55.  
  56. Show most frequently executed commands (I call it "lastfreq");
  57.  
  58.     lastcomm | sed 's/ .*//' | sort | uniq -c | sort -rn
  59.