Date: Wed, 25 Jan 2006 01:19:18 -0500 (EST) From: Ensel Sharon <user@dhp.com> To: Luke Bakken <luke.bakken@gmail.com> Cc: freebsd-questions@freebsd.org Subject: Re: shell scripting question (mdconfig device choosing) Message-ID: <Pine.LNX.4.21.0601250117150.8684-100000@shell.dhp.com> In-Reply-To: <6acc6ca40601241935h290738e1scee8af44dc144224@mail.gmail.com>
next in thread | previous in thread | raw e-mail | index | archive | help
Luke, On Tue, 24 Jan 2006, Luke Bakken wrote: > > 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}=(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 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 it just for this one shell script :(
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.LNX.4.21.0601250117150.8684-100000>