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.

2 comments on “pear list

  1. 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

    Reply

Leave a Reply