[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Vá: awk FIELDWIDTHS howto?



2008/1/9, Paul Csanyi <csanyipal@gmail.com>:
> 2008/1/9, Sergio Cuéllar Valdés <herrsergio@gmail.com>:
> > 2008/1/9, Paul Csanyi <csanyipal@gmail.com>:
>
> > > I try to use awk to print second field from a text file
> > > but awk prints a part of 1. field as a 2. field. Why?
> > >
> > > aptitude search ~i | awk '{ NF = "2" } { FIELDWIDTHS = " 4 32 " }
> > > {print $2}' > foltelepitett_debian_csomagok
> > >
> > > less foltelepitett_debian_csomagok
> > >
> > > ..
> > > bsdmainutils
> > > bsdutils
> > > busybox
> > > A
> > > ca-certificates
> > > checksecurity
>
> A record is like these:
>
> i busybox - Tiny utilities for small and embedded syst
> i A bzip2 - high-quality block-sorting file compressor
>     |
> 1234123456789etc.
> 1.  |2.
>
> I try to get only the package name from the 2. field.
>
> FIELDWIDTHS = " 4 32 "
>
> The given width for 1. field (4) should be right, but isn't.
> Awk give me the letter "A" as a 2. field. Why?
>
> > something like this:   aptitude search ~i | cut -d" " -f2
> > does this help you ?
>
> No.

So, if you only need package name:

 aptitude search ~i | cut -d" " -f3

Regards,
Sergio Cuellar


-- 
"Meine Hoffnung soll mich leiten
Durch die Tage ohne Dich
Und die Liebe soll mich tragen
Wenn der Schmerz die Hoffnung bricht"


Reply to: