[BlueOnyx:06701] Re: fwiw

Larry Smith lesmith at ecsis.net
Wed Mar 16 08:50:57 -05 2011


On Wed March 16 2011 07:57, Gerald Waugh wrote:
> On Wed, 2011-03-16 at 17:17 +1100, David Booth wrote:
> > I wanted to find all the users who have a .forward, and what's in it.
> >
> > So I made lookforward.sh
> >
> > #! /bin/bash
> > ls /home/sites > sitelist.txt
> > cat sitelist.txt | while read line;
> > do
> >          site=$line
> >          ls /home/sites/$site/users > tmp
> >          cat tmp | while read line;
> >          do
> >                  if [ -f /home/sites/$site/users/$line/.forward ]
> >                  then
> >                          echo
> > ___________________________________________; echo $site;
> >                          echo $line;
> >                          cat /home/sites/$site/users/$line/.forward
> >                          echo
> > ___________________________________________; fi
> >                  done
> > done
>
>   rm sitelist.txt tmp
>
> > I still have to munge it to get what I really need but it beats doing it
> > one by one.
> >
> > Enjoy.

RE-write that only gives the site name, user name and forwarding
email if any is present:

---------cut-----------
#!/bin/bash

for site in `ls /home/sites`
do
  for users in `ls /home/sites/$site/users`
  do
    if [ -f /home/sites/$site/users/$users/.forward ]
    then
      FWD=`grep -v "^#" /home/sites/$site/users/$users/.forward`
      if [ -z $FWD ]
      then
        echo -n "$site:$users:EMPTY"
      else
        echo -n "$site:$users:$FWD"
      fi
    fi
    echo ""
  done
done
-------cut----------

-- 
Larry Smith
lesmith at ecsis.net



More information about the Blueonyx mailing list