From owner-freebsd-questions@FreeBSD.ORG Mon Jun 21 13:21:11 2010 Return-Path: Delivered-To: questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id D3F0D1065675 for ; Mon, 21 Jun 2010 13:21:11 +0000 (UTC) (envelope-from aiza21@comclark.com) Received: from avmxsmtp3.comclark.com (avmxsmtp3.comclark.com [202.69.191.117]) by mx1.freebsd.org (Postfix) with ESMTP id 6AE718FC1B for ; Mon, 21 Jun 2010 13:21:11 +0000 (UTC) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Aj8SAKMDH0zKRa1mPGdsb2JhbAAHh2iXKwEBAQE1wiiCWIJDBINS X-IronPort-AV: E=Sophos;i="4.53,453,1272816000"; d="scan'208";a="4686468" Received: from unknown (HELO [10.0.10.3]) ([202.69.173.102]) by avmxsmtp3.comclark.com with ESMTP; 21 Jun 2010 21:21:09 +0800 Message-ID: <4C1F6746.4050400@comclark.com> Date: Mon, 21 Jun 2010 21:21:10 +0800 From: Aiza User-Agent: Thunderbird 2.0.0.17 (Windows/20080914) MIME-Version: 1.0 To: =?ISO-8859-1?Q?Samuel_Mart=EDn_Moro?= References: <4C1F4B4C.2000006@comclark.com> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit Cc: "questions@freebsd.org" Subject: Re: .sh for loop X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 21 Jun 2010 13:21:11 -0000 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?