FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > Debian > Debian User

 
 
LinkBack Thread Tools
 
Old 01-09-2008, 07:10 PM
"Paul Csanyi"
 
Default Vá: Vá: awk FIELDWIDTHS howto?

2008/1/9, Sergio Cuéllar Valdés <herrsergio@gmail.com>:
> 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?

> So, if you only need package name:
>
> aptitude search ~i | cut -d" " -f3

It is cut, not awk.
Howewer, it is not god. The output file contains empty lines
besides of the package names.

--
Regards, Paul Csanyi
http://www.freewebs.com/csanyi-pal/index.htm
 
Old 01-09-2008, 07:16 PM
"Sergio Cuéllar Valdés"
 
Default Vá: Vá: awk FIELDWIDTHS howto?

2008/1/9, Paul Csanyi <csanyipal@gmail.com>:
> > So, if you only need package name:
> >
> > aptitude search ~i | cut -d" " -f3
>
> It is cut, not awk.
> Howewer, it is not god. The output file contains empty lines
> besides of the package names.

No blank lines : aptitude search ~i | cut -d" " -f3 | sed '/^$/d'

done

yes, no awk


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


--
To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
 
Old 01-09-2008, 07:33 PM
Florian Kulzer
 
Default Vá: Vá: awk FIELDWIDTHS howto?

On Wed, Jan 09, 2008 at 14:16:38 -0600, Sergio Cuéllar Valdés wrote:
> 2008/1/9, Paul Csanyi:
> > > So, if you only need package name:
> > >
> > > aptitude search ~i | cut -d" " -f3
> >
> > It is cut, not awk.
> > Howewer, it is not god. The output file contains empty lines
> > besides of the package names.
>
> No blank lines : aptitude search ~i | cut -d" " -f3 | sed '/^$/d'
>
> done
>
> yes, no awk

You can tell aptitude that you want a list of only the package names:

aptitude -F%p search ~i

--
Regards, | http://users.icfo.es/Florian.Kulzer
Florian |
 

Thread Tools




All times are GMT. The time now is 07:19 AM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2007 - 2008, www.linux-archive.org