pkg_info output? 'homework' clarification sought...
David Armour
dfarmour at myrealbox.com
Tue May 3 13:18:13 PDT 2005
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.
More information about the freebsd-questions
mailing list