Many times I want to take the output of emerge -p, and put the list of packages into /etc/portage/package.*. I haven't found an easy way of doing that with emerge itself (-p and -vp give too much info for this purpose), so I wrote a filter in Perl to do it. Basically, at the moment on my system if I issue this command, I get the following output:

You can add keywords to the output, say for adding to package.use or package.keywords, just use the -k or --keyword option, followed by a string (like "~x86" or "gtk -qt"). There's also a -V or --versions option, to display package versions.

looks cool. How about adding an option to append the version number to packages as well? Useful when one wants to do stuff like >=package-#.#.#

There's already the -V or --versions option, lemme know if it's not working for you. Or do you want a specific version that's not listed in emerge -vp output? I'm not sure that's feasible, since in most cases you won't want the exact same version for all packages in the list (unless you're merging something like KDE or GNOME).

I have no intention to steal the glory of your fine perl work, but I find <awk pipeline> a little niftier.

It's been my experience that awk is more concise on the command line than Perl, but I've never figured out how to encapsulate awk into a script (of course, that's probably because I learned Perl long before I ever witnessed the power of awk). For something quick and dirty (quicker and dirtier than Perl even), I'd suggest awk. But again, I don't really know awk, so I wouldn't know how to recreate your pipeline from memory.

I have no intention to steal the glory of your fine perl work, but I find <awk pipeline> a little niftier.

It's been my experience that awk is more concise on the command line than Perl, but I've never figured out how to encapsulate awk into a script (of course, that's probably because I learned Perl long before I ever witnessed the power of awk). For something quick and dirty (quicker and dirtier than Perl even), I'd suggest awk. But again, I don't really know awk, so I wouldn't know how to recreate your pipeline from memory.

And I think in Perl now, so it's moot. (-:

A pure awk script:

Code:

#!/bin/awk -f
<awk code>

Encapsulated in a bash script, for instance:

Code:

#!/bin/bash
<bash code>
awk '
<awk code>
'

I don't know perl, but I assume things wouldn't look much different if perl allows for calling external programs...?

EDIT: Oh, and while on the subject, my little pipe is trivial in terms of the power of awk; however, it nicely illustrates the amazing capabilities of regexps...

regexps kickass. I use them heavily in Perl. I've heard the regexps in Perl are more powerful than in awk, but I have no experience to backup that claim.

I always thought they were a standard?

No, there are a number of "standards" for regex. There are regex, and extended regex (which is a POSIX standard), and perl compatible regular expressions (pcre) and (probably) some more. Many GNU apps/tools, however, share some common method for regex, perhaps with a couple of permutations.

Perl does add a bit of functionality to the "typical" regex used in tools like sed and grep (course, grep -E or egrep adds extended regex functionality).

<...>
Regular Expressions
Regular expressions are the extended kind found in egrep.
<...>

Which should be the POSIX standard I beleive. I think all the GNU tools follow this POSIX standard (grep, sed, awk, et cetera).

Quote:

Wikipedia wrote:

Perl has a richer and more predictable syntax than even the extended POSIX regexp.

Answers that question, I guess.

Wikipedia to the rescue Seriously, isn't it about time that "wikipedia" got verbed like "google" has? I've been using it ("Just wikipedia that"). Woo for neo-colloquialisms._________________Carlton Stedman
Gentoo Metalheads on Last.fm: http://www.last.fm/group/Gentoo+Metalheads