Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 21 Jun 2010 21:21:10 +0800
From:      Aiza <aiza21@comclark.com>
To:        =?ISO-8859-1?Q?Samuel_Mart=EDn_Moro?= <faust64@gmail.com>
Cc:        "questions@freebsd.org" <questions@freebsd.org>
Subject:   Re: .sh for loop
Message-ID:  <4C1F6746.4050400@comclark.com>
In-Reply-To: <AANLkTinB6FkugAD0GXlF3t-n5dbX39nstbxSxlCxiHje@mail.gmail.com>
References:  <4C1F4B4C.2000006@comclark.com> <AANLkTinB6FkugAD0GXlF3t-n5dbX39nstbxSxlCxiHje@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
Samuel Martín Moro wrote:
> it seems to work
> 
> your main error is to use ${found_name} instead of ${name}.
> also, you do not set ${group} in your example.
> and, not essential, but test -z before adding useless spaces.
> correcting that, I had it working perfectly.
> 
> h2g2:~# cat test
> path=/dev
> group=tty
> for name in "${path}/${group}"*
> do
>     [ -z "${found_list}" ] && found_list="${name}" || 
> found_list="${found_list} ${name}"
> done
> echo "found list: $found_list"
> h2g2:~# sh test
> found list: /dev/ttyU0 /dev/ttyU0.init /dev/ttyU0.lock /dev/ttyd0 
> /dev/ttyd0.init /dev/ttyd0.lock /dev/ttyp0 /dev/ttyp1 /dev/ttyp2 
> /dev/ttyp3 /dev/ttyp4 /dev/ttyp5 /dev/ttyp6 /dev/ttyp7 /dev/ttyv0 
> /dev/ttyv1 /dev/ttyv2 /dev/ttyv3 /dev/ttyv4 /dev/ttyv5 /dev/ttyv6 
> /dev/ttyv7 /dev/ttyv8 /dev/ttyv9 /dev/ttyva /dev/ttyvb /dev/ttyvc 
> /dev/ttyvd /dev/ttyve /dev/ttyvf
> h2g2:~#
> 

Ok lets say that group had a value in it that was not found.
How do i identify that condition?



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?4C1F6746.4050400>