[nycbug-talk] pkg_info

Marc Spitzer mspitze1
Mon Feb 23 18:26:36 EST 2004


On Mon, 23 Feb 2004 18:15:56 -0500
Marc Spitzer <mspitze1 at optonline.net> wrote:

> On Mon, 23 Feb 2004 16:50:07 -0500
> jc <jesse at theholymountain.com> wrote:
> 
> > I'm not in love with myself or anything, but I like to check my
> > packages every once in a while. I was doing some stuff [which I'd
> > probably have never ventured to do w/o the help of freebsddiary.org]
> > and needed to get the installed packages without the descriptions. I
> > made a perl script which would s/^ +$//. It was a little more than a
> > one-liner, but I had to... let me be explicit:
> > 
> > 
> > open PKG, "pkg_info |";
> > while (<PKG>) {
> >     s/^ +$//;   # theres a space between ^ +
> >     print;
> > }

Forgot to mention before your RE is wrong, it says "from the begining of
the line match all the
spaces to the end of the line and substatute with nothing"  Try this one
instead:

/^(\S+)\s/ 

ie
pkg_info |perl -ne ' /^(\S+)\s/ ; print "$1\n";'

and perldoc -f split

marc

> 
> man awk.
> 
> ie 
> 
> pkg_info |awk '{print $1}'
> 
> assumes pkg_info output looks like this:
> 
> xview-3.2.1_2       X Window-System-based Visual/Integrated
> Environment for Wor
> yencode-0.46_1      A free (GPL) encoder and decoder for the yEnc
> Usenet file f
> 
> marc
> 
> ps cut would also work, but only on the first field, hint man cut
> 
> 
> 
> > 
> > How else can I do this? Whats the regex to use in sed? I know it's
> > boring, but I'm bored.
> > 
> > 
> > _______________________________________________
> > talk mailing list
> > talk at lists.nycbug.org
> > http://lists.nycbug.org/mailman/listinfo/talk
> _______________________________________________
> talk mailing list
> talk at lists.nycbug.org
> http://lists.nycbug.org/mailman/listinfo/talk




More information about the talk mailing list