tail -f used to start a script 

From: Vic Glass @injersey.infi.net
> I need to monitor the output of a program and start a script when
> a specific word is in the output. That is, whenever the program
> writes ADMIN, I want to be automatically notified.

A Bourne Shell solution:

tail -f |
while read line
do
    if expr "$line" : '.*ADMIN.*'
    then
        mailx you <<-!
        message of your choice
        !
    fi
done

documented on: 04-25-99 13:26:51

xargs1 

#!/bin/sh
# xargs1
# Almost like xargs but,
# It fix n=1 (one parameter at a time), and it can use more than one
# instance of {} to represent the

#set -xv

if [ "$1" = "-v" ] ; then
  sonly=1  # show cmd to be executed only
  shift
else
  sonly=0
fi

# if no {} supplied on command line,
# add at the end
echo $* | grep '\{\}' >/dev/null
if [ $? -eq 1 ] ; then set -- $* "{}" ; fi

while read ii ; do
  cmd=`echo $* | sed -e "s|{}|$ii|g"`
  echo
  echo ">$cmd"

  #X exec $cmd # only once!?
  if [ !$sonly ] ; then eval $cmd ; fi
  #  *N*: "! $sonly" will not work!
  #       no space allowed after "!"
  #       also can issure $cmd directly without eval, if no redirect envolved
done

Misc Shell Scripts Tools in Bin 

>     #!/bin/sh
>
>     set -- "hinv" "df -k" "gfxinfo" "uname -a"       # etc.
>
>     for cmd in "$@"; do
>        echo "$cmd"
>        echo "\n\n$cmd\n--------------------" >> temp$$
>        $cmd >> temp$$
>     done

T_lc 

 > cat t_lc
#!/bin/csh
#
#echo $*
foreach i ( $* )
        set newfile = `echo $i | tr '[A-Z]' '[a-z]'`
        echo $newfile
        mv $i $newfile
end
Note specifing '#!/bin/csh' in vitally important! otherwise, won't work.

T_u 

 > cat t_u
#!/bin/csh
#
#echo $*
foreach i ( $* )
        set newfile = `echo $i | tr '[A-Z]' '[a-z]'`
        echo $newfile
        dos2unix $i $newfile
        rm $i
end

T_d 

#!/bin/csh
#
#echo $*
foreach i ( $* )
        set newfile = `echo $i | tr '[A-Z]' '[a-z]'`
        #echo $newfile
        unix2dos $i $newfile
        rm $i
end

T_uc 

#!/bin/csh
#
#echo $*
foreach i ( $* )
        set newfile = `echo $i | tr '[a-z]' '[A-Z]'`
        #echo $newfile
        mv $i $newfile
end

documented on: 11:43:05

Misc tools example & history 

awk -F\t '{print $2}' <lget-log.txt  | sort | uniq >url.lst
grep '/$' url.lst | xargs -n 1 lwp-download -qbl lget-log.txt
cut -c6- common | perl -pe 's/^(.*)\n/"$1", /'

— add "", to word and del the \n

documented on: Thu 03-18-99 19:40:14