From owner-freebsd-questions@FreeBSD.ORG Tue Jan 24 22:50:12 2006 Return-Path: X-Original-To: freebsd-questions@freebsd.org Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 5EF6F16A41F for ; Tue, 24 Jan 2006 22:50:12 +0000 (GMT) (envelope-from user@dhp.com) Received: from shell.dhp.com (shell.dhp.com [199.245.105.1]) by mx1.FreeBSD.org (Postfix) with ESMTP id 8C54643D4C for ; Tue, 24 Jan 2006 22:50:09 +0000 (GMT) (envelope-from user@dhp.com) Received: by shell.dhp.com (Postfix, from userid 896) id C87D4312F5; Tue, 24 Jan 2006 17:50:05 -0500 (EST) Date: Tue, 24 Jan 2006 17:50:05 -0500 (EST) From: Ensel Sharon To: Chuck Swiger In-Reply-To: <43D6A62B.80001@mac.com> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Cc: freebsd-questions@freebsd.org Subject: Re: shell scripting question (mdconfig device choosing) 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: Tue, 24 Jan 2006 22:50:12 -0000 On Tue, 24 Jan 2006, Chuck Swiger wrote: > Ensel Sharon wrote: > > and I know how to use awk to strip away the leading "md" from each piece > > of the output ... but I do not know how to take output like: > > > > 8 9 11 14 > > > > and decide that the lowest available number is "0". How can I do this ? > > % echo '9 8 11 14' | sort -nt ' ' | head -1 > 8 Yeah, but I am looking for "0" ... 8,9,11,14 are all in use ... but 0-7 are not. I want to: "starting with zero, find the lowest number that is NOT in this list" (where "this list" is the output of mdconfig -l, which shows which md devices are currently in use) Thanks.