.sh for loop
Aiza
aiza21 at comclark.com
Mon Jun 21 13:21:11 UTC 2010
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?
More information about the freebsd-questions
mailing list