Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

select a column 1

Status
Not open for further replies.

Yarka

Technical User
Jan 14, 2007
192
ES
Hi, im trying to get, for example the fifth column from a file using awk.
I have a file as:

0.1 0.2 . 0.55 0.2 0.3
6.5 0.2 0.1 . 0.2 0.3
5.1 0.1 0.1 0.1 0.1 .
0.3 0.2 . . 1.5 5.3
0.3 1.2 4.2 6.3 . 4.3
2.3 2.5 8.4 6.3 0.2 3.5

I have put . where a tabulation exists (but in my original file these .'s don't exist, only I have put it for explain better the problem)

I try to use awk, but my problem is that not all positions have a value. By each column has a tabulation
independently of if it has a value or no.

How is it possible to be used that by each tabulation (independently if it exists or not a value) it counts like a column, for then to be able to do {print $5} ?

Thanks.
 
You need to define tab as your column/field separator:

[tt]awk -F'<tab>' '{print $5]'[/tt]

Where you should replace <tab> with a tab character.

Annihilannic.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top