A few of my favorite pipes...
Phil Budne
budd at bu-it.bu.edu
Wed Jul 4 07:25:01 AEST 1990
A few weeks ago favorite pipes were a topic on unix-wizards. Here are
a few of my favorite pipes ( to tune of "my favoite things" ) I
collected in the process of cleaning up in preparation for leaving my
job;
For seeing if anything of mine is stuck in the mqueue (I call it "mq");
#!/bin/sh
# display my items in the mail queue
if [ $# -gt 0 ]; then
who=$1
else
who=`whoami`
fi
echo Pending messages on `hostname` from user $who
#
mailq | \
awk " BEGIN { pr = items = found = 0; } \
/^AA/ { if( \$0 ~ /$who/ || \$0 ~ /$who\@\.\*/ ) { \
pr = 1; found++; } \
else { pr = 0; } items++; } \
{ if( pr ) print } \
END { if( found > 0 ) fm = \"(\" found \" displayed)\";
print items \" total \" fm } "
A summation of rwho output (I call it "uz");
#!/bin/sh
if tty -s <&1;
then
rwho $* | sed 's/[ ].*//' | uniq | fmt
else
rwho $* | sed 's/[ ].*//' | uniq
fi
A count of users as displayed by "uz" (I call it "uc");
rwho $* | sed 's/[ ].*//' | uniq | wc -l
For seeing what batched news is queued for a site (I call it "gq")
#/bin/sh
# NOTE! our /usr/spool/news is in /news
SPOOLDIR=/news
if [ "$1" -a -f $SPOOLDIR/batch/$1 ]; then
sed -e 's@/[0-9].*$@@' \
-e "s@^$SPOOLDIR/@@" \
-e 's@/@. at g' < /usr/spool/news/batch/$1 |\
sort | uniq -c | sort -rn
fi
Show most frequently executed commands (I call it "lastfreq");
lastcomm | sed 's/ .*//' | sort | uniq -c | sort -rn
More information about the Alt.sources
mailing list