Re: Bug in wc???

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Am Sonntag 11 Januar 2004 15:53 schrieb Ben Steeves:
> 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@homer dnetc483-linux-x86-elf]$ ls|wc -l
> >       6
> > [frank@homer dnetc483-linux-x86-elf]$
> > but at all scipt saples the output are:
> > [xxxx@xxx]$ ls|wc -l
> >  x
> > [xxxx@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@phalanx bcs]$ ls | wc -l
>     126
> [bcs@phalanx bcs]$ echo `ls | wc -l`
> 126
works, but my script will not her the code:

#!/bin/sh
Zeilen= echo `cat /tmp/test.txt |wc -l`
if [ $Zeilen > 3 ]; then
echo "Update";
else
echo "kein Update";
fi

i get every time the output:
4
kein Update
but the file has 4 lines
what is wrong?????
> [bcs@phalanx bcs]$ if [ `ls | wc -l` == 126 ]; then echo "OK"; fi
> OK
>
> ...basically, the shell commands will swallow the extra spaces.
>
> --
> Ben Steeves                     _                    bcs@xxxxxxxxxx
>  The ASCII ribbon campaign     ( )               ben.steeves@xxxxxx
>    against HTML e-mail          X                GPG ID: 0xB3EBF1D9
> http://www.metacon.ca/ascii    / \     Yahoo Messenger: ben_steeves




[Index of Archives]     [Current Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]     [Fedora Docs]

  Powered by Linux