From owner-freebsd-questions@FreeBSD.ORG Wed Jan 25 03:35:55 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 4925616A41F for ; Wed, 25 Jan 2006 03:35:55 +0000 (GMT) (envelope-from luke.bakken@gmail.com) Received: from uproxy.gmail.com (uproxy.gmail.com [66.249.92.193]) by mx1.FreeBSD.org (Postfix) with ESMTP id 9FE7143D45 for ; Wed, 25 Jan 2006 03:35:54 +0000 (GMT) (envelope-from luke.bakken@gmail.com) Received: by uproxy.gmail.com with SMTP id o2so17744uge for ; Tue, 24 Jan 2006 19:35:53 -0800 (PST) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=R/+ZIEvY5fqrcCkLFp9KJS3uolLd3eWorVW3fKCNs932Pom9h6dqMEmgOJnAv5DqhgRcKk5gvLIMHerRiZ/eMUoz8RQs2Syem1RI8hs7Jj0U51UaUMdBbAbtJ2uBlseAxGjtaFQe0XfdRfTFgko+pB3QjklSVwqNRQfM7jW9vOE= Received: by 10.48.235.6 with SMTP id i6mr19077nfh; Tue, 24 Jan 2006 19:35:49 -0800 (PST) Received: by 10.49.28.15 with HTTP; Tue, 24 Jan 2006 19:35:49 -0800 (PST) Message-ID: <6acc6ca40601241935h290738e1scee8af44dc144224@mail.gmail.com> Date: Tue, 24 Jan 2006 19:35:49 -0800 From: Luke Bakken To: Ensel Sharon In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline References: <43D6A62B.80001@mac.com> 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: Wed, 25 Jan 2006 03:35:55 -0000 > > Ensel Sharon wrote: > > > and I know how to use awk to strip away the leading "md" from each pi= ece > > > 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 thi= s ? > > > > % 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) Running mdconfig -l I don't get any output, however this works, it'll find the first unused number up to 25 in that list. echo '8 9 11 14' | perl -ane'@h{@F}=3D(1)x@F;for(0..25){if(not defined $h{$_}){print qq($_\n);exit}}' If you can give me the exact output of mdconfig -l, I can modify this for y= ou. Luke