pear list

I’ve been tinkering with PEAR at work, switching between using portage to install stuff and sometimes using pear directly to install it.

One thing that’d be nice is to get a list of the packages installed in pear command-line syntax. I.e. pear install MDB2-beta.

So, here’s a quick reference to convert the output of “pear list” to a list you can use with pear:

pear list | egrep "(stable|beta|alpha)$" | while read line; do echo $line | cut -d " " -f 1,3 --output-delimiter=-; done

A sample output would be:

$ pear list
INSTALLED PACKAGES, CHANNEL PEAR.PHP.NET:
=========================================
PACKAGE VERSION STATE
Archive_Tar 1.3.7 stable
Auth_SASL 1.0.4 stable
Console_Color 1.0.3 stable
Console_Getopt 1.2.3 stable
Console_Table 1.1.4 stable
Crypt_HMAC 1.0.1 stable

to this:

Archive_Tar-stable
Auth_SASL-stable
Console_Color-stable
Console_Getopt-stable
Console_Table-stable
Crypt_HMAC-stable
etc …

For me it’s just a nice way to backup the pear module list, or copy it to a file and then install the pear modules on another box.

About these ads

2 Comments

Filed under Programming

2 responses to “pear list

  1. Lonnie Olson

    Simplified.
    pear list | awk ‘/(stable|beta|alpha)/{print $1 “-” $3}’

  2. Lonnie Olson

    Or, to be more resilient to different states, just remove the first 3 lines.
    pear list | awk ‘NR>3{print $1 “-” $3}’

    awk rulez

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s