Re: Vá: awk FIELDWIDTHS howto?
On Wed, Jan 09, 2008 at 08:48:38PM +0100, Paul Csanyi wrote:
> 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
This will give you what you want:
aptitude search ~i | awk '{ print substr($0,5,32) }'
--
"The Achilles' heel of authoritarianism is that the leader by the very
nature of his position is able to ignore the wisdom of anyone "below"
him--that is, anyone who stands between him and the real world. This is
what authority means: immunity from competence." -- Philip Slater
Rick Pasotto rick@niof.net http://www.niof.net
Reply to: