Bug in wc???

Ben Steeves bcs at metacon.ca
Sun Jan 11 14:53:18 UTC 2004


On Sun, 2004-01-11 at 10:45, Hans Müller wrote:
> Hello when  i use the wc command i get many spaces. 
> for example:
> [frank at homer dnetc483-linux-x86-elf]$ ls|wc -l
>       6
> [frank at homer dnetc483-linux-x86-elf]$
> but at all scipt saples the output are:
> [xxxx at xxx]$ ls|wc -l
>  x
> [xxxx at xxx]$
> so i cannot use the output in a script. Who can help?

It's not a bug -- it's the way wc has worked since time immemorial. 
Observe:
[bcs at phalanx bcs]$ ls | wc -l
    126
[bcs at phalanx bcs]$ echo `ls | wc -l`
126
[bcs at phalanx bcs]$ if [ `ls | wc -l` == 126 ]; then echo "OK"; fi
OK

...basically, the shell commands will swallow the extra spaces.

-- 
Ben Steeves                     _                    bcs at metacon.ca
 The ASCII ribbon campaign     ( )               ben.steeves at unb.ca
   against HTML e-mail          X                GPG ID: 0xB3EBF1D9
http://www.metacon.ca/ascii    / \     Yahoo Messenger: ben_steeves





More information about the fedora-list mailing list