From owner-freebsd-questions@FreeBSD.ORG Tue May 3 20:18:13 2005 Return-Path: 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 8295E16A4CE for ; Tue, 3 May 2005 20:18:13 +0000 (GMT) Received: from pd3mo1so.prod.shaw.ca (shawidc-mo1.cg.shawcable.net [24.71.223.10]) by mx1.FreeBSD.org (Postfix) with ESMTP id 2C06443D75 for ; Tue, 3 May 2005 20:18:13 +0000 (GMT) (envelope-from dfarmour@myrealbox.com) Received: from pd5mr7so.prod.shaw.ca (pd5mr7so-qfe3.prod.shaw.ca [10.0.141.183]) by l-daemon (Sun ONE Messaging Server 6.0 HotFix 1.01 (built Mar 15 2004)) with ESMTP id <0IFX00LDWKCVG330@l-daemon> for freebsd-questions@freebsd.org; Tue, 03 May 2005 14:17:19 -0600 (MDT) Received: from pn2ml6so.prod.shaw.ca ([10.0.121.150]) by pd5mr7so.prod.shaw.ca (Sun ONE Messaging Server 6.0 HotFix 1.01 (built Mar 15 2004)) with ESMTP id <0IFX0061CK9874H0@pd5mr7so.prod.shaw.ca> for freebsd-questions@freebsd.org; Tue, 03 May 2005 14:15:08 -0600 (MDT) Received: from S0106000d87ae2db6.gv.shawcable.net (S0106000d87ae2db6.gv.shawcable.net [24.108.146.24]) by l-daemon (iPlanet Messaging Server 5.2 HotFix 1.18 (built Jul 28 2003)) with ESMTP id <0IFX00K4AK978R@l-daemon> for freebsd-questions@freebsd.org; Tue, 03 May 2005 14:15:08 -0600 (MDT) Date: Tue, 03 May 2005 13:15:19 -0700 From: David Armour In-reply-to: <20050502120100.B872116A525@hub.freebsd.org> To: freebsd-questions@freebsd.org, Toni Schmidbauer Message-id: <200505031315.19584.dfarmour@myrealbox.com> Organization: dfarmour.org MIME-version: 1.0 Content-type: text/plain; charset=iso-8859-1 Content-transfer-encoding: 7bit Content-disposition: inline References: <20050502120100.B872116A525@hub.freebsd.org> User-Agent: KMail/1.8 Subject: Re: pkg_info output? 'homework' clarification sought... X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 03 May 2005 20:18:13 -0000 hello, sorry: clicked wrong icon, & truncated my reply/question. i think. i hope my lame-ish attempt at 'homework' doesn't screw with the list charter. i offer it in a spirit of open-source newbie encouragement. [note from previous message, orphaned by my mistake: [a] In a context address, any character other than a backslash (``\'') or newline character may be used to delimit the regular expression. ] > > pkg_info | sort | sed -e 's/-[0-9].*$//' | uniq -c | grep -v > > '^[[:space:]]*1' >1),>2),>3)... in previous mis-sent message. > 4) grep -v '^[[:space:]]*1' > ... deletes lines where only 1 version exists, e.g.: grep -v, --invert-match # Invert the sense of matching, to select non-matching lines. A bracket expression is a list of characters enclosed by [ and ]. It matches any single character in that list; if the first character of the list is the caret ^ then it matches any character not in the list. ... Finally, certain predefined named classes of characters are ... [:space:] .... The caret ^ and the dollar sign $ are metacharacters that respectively match the empty string at the beginning and end of a line. i'd assumed [bad!] that the '-v' represented 'verbose' as it does with several other commands. but the overall structure, if that's the right word, of the grep part of the tip seems a bit like a double negative, what with the '^' HOMEWORK portion: > the script is not quite correct because these two packages are > counted as two versions of xorg-fonts: > xorg-fonts-100dpi-6.8.2 > xorg-fonts-75dpi-6.8.2 > > pkg_info | sort | sed -e 's/-[0-9].*$//' | uniq -c | grep -v > > '^[[:space:]]*1' so 2 hits out of 360 odd packages compromise otherwise informative results? and assuming, for the moment, that everyone here understands that the ideas expressed *here* are coming from about as far out in left field as is possible... ? as i understand things, so far: sed gets a list of sorted stuff that looks like: autoconf-6.8.2.... borg-6.8.2 ... perl-6.8.2... xorg-fonts-100dpi-6.8.2 xorg-fonts-75dpi-6.8.2 and uniq counts instances of duplication so the list now looks like: 3 autoconf-6.8.2 1 borg-6.8.2 ... 2 perl-6.8.2 2 xorg-fonts-100dpi-6.8.2 the tip asks sed to look in a sorted list of installed packages for instances of hyphens followed by numerals between 0-9. i'm guessing that sed either needs to incorporate a check within its own results (maybe a set of brackets with a second sed -e 's/-[0-9].*$//' |)?, *before* uniq gets its hands on it, or some sort of if/then condition programming wizardry to scarf up potential stragglers. of course, at this stage in my travels in unix-land, i have no idea, clear or unclear how such twickery might occur. nonetheless, the natives appear friendly.