Mailinglist Archive: opensuse (3336 mails)

< Previous Next >
Re: [SLE] using wc -l in loop
  • From: John Summerfield <suse@xxxxxxxxxxxxxxxxxxxxxx>
  • Date: Thu, 1 Dec 2005 21:36:43 +0800 (WST)
  • Message-id: <Pine.LNX.4.62.0512012129100.562@xxxxxxxxxxx>
On Thu, 1 Dec 2005, Simon Roberts wrote:

> I think the syntax you want will be based on this:
>
> for x in list
> do
> stuff...
> done | wc -l
>
> That'll pipe the output from the loop for you
>
> If you need the output to go to wc in addition to its normal
> destination, then use tee (... done | tee | wc -l )
>
> HTH
> Cheers,
> Simon
>
>
> --- Arie Reynaldi Z <reymanx@xxxxxxxxx> wrote:
>
> > Hi All,
> >
> > I'd like to make a list members and total member from my milis using
> > ezmlm-list. I make this script:
> >
> > #!/bin/bash
> > echo Lihat user, masukan username tanpa domain
> > read mail
> > a=`/usr/local/bin/ezmlm/ezmlm-list
> > /home/vpopmail/domains/domai.com/staff | grep $mail | sort `

Some find this construct clearer:
a=$(/usr/local/bin/ezmlm/ezmlm-list /home/vpopmail/domains/domai.com/staff | grep $mail | sort)
Especially when nesting.

(I don't know the command, don't know just where line breaks should be)

Both have the potention to make a too-big commandline, so ...
#!/bin/bash
echo Lihat user, masukan username tanpa domain
read mail
/usr/local/bin/ezmlm/ezmlm-list /home/vpopmail/domains/domai.com/staff | grep $mail | sort \
| while read x1
do
echo staff $x1
done | wc -l


> > for x1 in $a ;
> > do echo staff $x1
> > done
> >
> > But I dont know where should I put 'wc -l' to know total of members..
> > Any idea ? Is there any other way beside using wc -l ?
> >

but if you're not writing anything for anyone to read, then
/usr/local/bin/ezmlm/ezmlm-list /home/vpopmail/domains/domai.com/staff | grep $mail | wc -l



> > regards,
> >
> > --
> > Arie Reynaldi Zanahar
> > reymanx at gmail.com
> > http://www.reynaldi.or.id
> >
> > --
> > Check the headers for your unsubscription address
> > For additional commands send e-mail to suse-linux-e-help@xxxxxxxx
> > Also check the archives at http://lists.suse.com
> > Please read the FAQs: suse-linux-e-faq@xxxxxxxx
> >
> >
> >
>
>
> "You can tell whether a man is clever by his answers. You can tell whether a man is wise by his questions." — Naguib Mahfouz
>
>
>
>
> __________________________________
> Yahoo! Mail - PC Magazine Editors' Choice 2005
> http://mail.yahoo.com
>
>
< Previous Next >
Follow Ups
References