sub a{printf"%7d "x@_."$f\n",@_ if@_}sub f{@l=@w=@c=();if(open z,$f){w +hile(<z> ){$c[0]+=length if$c;$l[0]++if$l&/\n/;$w[0]+=s/\S+//g if$w;}close z;$o +[0]+=$l[ 0]if$l;$p[0]+=$w[0]if$w;$q[0]+=$c[0]if$c}else{$e=warn"$0: $f: $!\n"}a@ +l,@w,@c} for(@ARGV){exit if/^-u$/&&warn"Usage: $0 [ -l ] [ -w ] [ -c ] file ... +\n";eval "\$$1=\@$1=0,next"if/^-([lwc])$/;push@f,$_}push@f,'-'if!@f;$l=$w=$c=1u +nless$l+ $w+$c;for$f(@f){&f}$f='total',a@o,@p,@q if@f>1;exit$e
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
(jeffa) Re: /bin/wc - exact behaviour
by jeffa (Bishop) on Dec 15, 2002 at 16:14 UTC |