Date: Tue, 03 May 2005 11:40:53 -0700 From: David Armour <dfarmour@myrealbox.com> To: freebsd-questions@freebsd.org, Toni Schmidbauer <toni@stderror.at> Subject: Re: pkg_info output? ... 'homework' clarification sought! Message-ID: <200505031140.54257.dfarmour@myrealbox.com> In-Reply-To: <20050502120100.B872116A525@hub.freebsd.org> References: <20050502120100.B872116A525@hub.freebsd.org>
next in thread | previous in thread | raw e-mail | index | archive | help
hello, thanks v. much for your kind reply. sorry for my delay in responding. i was heading off to work when i first saw your message. the translation of the tip segments helps immensely. as for the "homework", well... i'm not 'there,' yet. some possible suspects: > On Sat, Apr 30, 2005 at 11:48:35PM -0700, David Armour wrote: > > pkg_info | sort | sed -e 's/-[0-9].*$//' | uniq -c | grep -v > > '^[[:space:]]*1' > > 0) pkg_info <= list all packages installed. yep > 1) sort <= sort resulting list by package name. gotcha. > 2) sed -e 's/-[0-9].*$//' <= delete everything after a dash followed by a number followed by everything else. (autoconf-2.59_2 >> autoconf) ... my understanding starts to go south 'round about here. i can see from sed's manpage(s): sed [-Ean] [-e command] ...that the command, the characters between the apostrophes, [a] appends "the editing commands specified by the command argument to the list of commands." nowhere on the manpage, however, can i find any reference to the 'delete' you mention. Waay down the page, in a thicket of sed "functions", i run across: [2addr]s/regular expression/replacement/flags *S*ubstitute the replacement string for the first instance of the regular expression in the pattern space. <snippage> A line can be split by substituting a newline character into it. To specify a newline character in the replacement string, precede it with a backslash. ... which, going out on the limb of my understanding, here, seems to match the intent, at least, of the 'delete' you point to. admittedly, i'm mostly grasping at straws in terms of what the '$' and the '//' are doing in there. and the warning in the "bugs" section... Multibyte characters containing a byte with value 0x5C (ASCII `\') may be incorrectly treated as line continuation characters in arguments to the ``a'', ``c'' and ``i'' commands. *Multibyte characters cannot be used as delimiters with the ``s'' and ``y'' commands.* ... seems to introduce the possibility, at least for 'homework' purposes, that the 'textbook' might have a typo as far as the "s" command. ??? > 3) uniq -c <= believe it or not, but earlier i had got a 'command not found' message when i tried to man uniq. after i saw your message i re-tried it and, of course, it worked. no idea what *that's* about! > -c Precede each output line with the count of the number of times > the line occurred in the input, followed by a single space. i see the sense of '-c' mapping to 'count'. i'm less clear about where the 'space', single or otherwise, comes in. [except that that's the spec!] > > pkg_info | sort | sed -e 's/-[0-9].*$//' | uniq -c | grep -v > > '^[[:space:]]*1' > so counts how often autoconf is in the list resulting from 2) > > 4) grep -v '^[[:space:]]*1' > > delete every line starting (^) with one or more space characters " " > followed by 1 in the list resulting from 3) > > this deletes lines where only 1 version exists, e.g.: > > 1 borg > > > 3 autoconf > > 3 automake > > 6 docbook > > 2 gcc > > 2 glib > > 2 gtk > > 2 libtool > > 2 perl > > 2 xorg-fonts > > so there are 3 versions of autoconf installed, 3 versions of > automake and so on. > > 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 > > homework: find a version that works :-) > > hth, [a] In a context address, any character other than a backslash (``\'') or newline character may be used to delimit the regular expression. > toni > -- > Wer es einmal so weit gebracht hat, dass er nicht | toni at stderror dot at > mehr irrt, der hat auch zu arbeiten aufgehoert | Toni Schmidbauer > -- Max Planck | > > ------------------------------
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200505031140.54257.dfarmour>