On Thu, 9 Dec 2004, Jacob Meuser wrote:

> On Thu, Dec 09, 2004 at 05:21:32PM -0800, Bob Miller wrote:
> > Jacob Meuser wrote:
> > 
> > > ah, nice.  I was worried about the leading spaces as well, but printf
> > > seems to take care of that:
> > > 
> > > $ tb=0; for i in *; do b=`wc -c < $i`; b=`printf "%d" $b`; \
> > > tb=`expr $tb + $b`; done; echo $tb
> > 
> > You didn't quote $b before passing it to expr, so the shell will strip
> > off spaces there.
> > 
> > $ tb=0; for i in *; do b=`wc -c < $i`; \
> >   tb=`expr $tb + $b`; done; echo $tb
> 
> didn't work for me.  shell is zsh 4.2.0 (i386-unknown-openbsd3.6).
> 
> expr: non-numeric argument
> expr: syntax error
> expr: syntax error
> expr: syntax error
> ...
> 
> -- 
> <[EMAIL PROTECTED]>

I'm not a zsh user.  But if you put the following into a file
and make it executable it will work no matter what shell you
normally use.

#!/bin/bash
typeset -i tb=0
for file in *; do tb=$tb+$(wc -c < $file); done
echo $tb

Well, actually, it has a defect.  It doesn't behave correctly
when $i is a directory.  Do you need this to work recursively
into subdirectories?
--
Allen Brown
  work: Agilent Technologies      non-work: http://www.peak.org/~abrown/
        [EMAIL PROTECTED]             [EMAIL PROTECTED]
  Isn't it a bit unnerving that doctors call what they do "practice"? --- 
George Carlin

_______________________________________________
EUGLUG mailing list
[EMAIL PROTECTED]
http://www.euglug.org/mailman/listinfo/euglug

Reply via email to