From owner-freebsd-questions@FreeBSD.ORG Wed Jan 25 15:17:46 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 55D3716A41F for ; Wed, 25 Jan 2006 15:17:46 +0000 (GMT) (envelope-from luke.bakken@gmail.com) Received: from uproxy.gmail.com (uproxy.gmail.com [66.249.92.202]) by mx1.FreeBSD.org (Postfix) with ESMTP id A572643D4C for ; Wed, 25 Jan 2006 15:17:45 +0000 (GMT) (envelope-from luke.bakken@gmail.com) Received: by uproxy.gmail.com with SMTP id o2so214692uge for ; Wed, 25 Jan 2006 07:17:45 -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=il/9SaLdkNUN7QpNCBohiiYvLzRt+2rJcWYtKu5tFFzKmw82yYV5pHJ+1dkqSWbPgPHnFLA/Q5hcIXhXg78+6Q13XRFtjqfzW3x5lsKfV7TDNqaVElRzykXpypR/CId/uG4LoE9VhWgJwFCy70r3/asNYuBI/mtryI+sYk1R+JY= Received: by 10.48.42.5 with SMTP id p5mr65464nfp; Wed, 25 Jan 2006 07:10:53 -0800 (PST) Received: by 10.49.28.15 with HTTP; Wed, 25 Jan 2006 07:10:53 -0800 (PST) Message-ID: <6acc6ca40601250710x3b0de685j2d7168f6ac5442a0@mail.gmail.com> Date: Wed, 25 Jan 2006 07:10:53 -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: <6acc6ca40601241935h290738e1scee8af44dc144224@mail.gmail.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 15:17:46 -0000 > > > 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 f= or you. > > > Thank you very much - you got no output because you have no md devices in > use. I have a few in use and this is the output I get: > > # mdconfig -l > md3 md2 md1 md0 > > But I could just as easily get: > > # mdconfig -l > md9 md8 md5 md3 > > Hmm...I just saw that that line is in perl, and I do not have perl > installed on any of my 6.0 machines ... I am not sure I want to install i= t > just for this one shell script :( Whoops, I forgot that perl isn't in the base any more. What scripting languages do you have? If you only have sh, I'll work on that, but it won't be a one-liner most likely. Or a C program.