begin  quoting John H. Robinson, IV as of Mon, Dec 03, 2007 at 01:26:42PM -0800:
> James G. Sack (jim) wrote:
[snip]
> > Making the perl a bit more meaningful.
> > (Maybe <someone> will offer a sed or awk version.)
> 
> A smart person would have realised that as soon as he reached for Perl,
> that was all he needed:
> 
> $ perl -ne '/^Package: (.*)/ and $p=$1;/^Description: (.*)/ and print "$p: 
> $1\n"' /var/lib/apt/lists/*Packages
> 
> sed:
> 
> $ sed -ne 's/^Package: \(.*\)/\1: /p; s/^Description: \(.*\)/\1/p' 
> /var/lib/apt/lists/*Packages
> 
> You will have to delete the extra newline yourself, I can't find a way
> to do it.
> 
> awk:
> 
> Left as an excercise for the reader.

cat /var/lib/apt/lists/*Packages | \
   awk 'BEGIN { s=0; FS=":" }; /^Package/ { s=0 ; print $2 } /^Tag/ { s=0 ; 
print "" } s==1 { printf(" "); print } /^Description/ { s=1 ; print " -" $2 ; }'

-- 
Others may refine it to delete lines consisting only of "." and spaces.
Stewart Stremler


-- 
[email protected]
http://www.kernel-panic.org/cgi-bin/mailman/listinfo/kplug-list

Reply via email to