The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com




Thread: Query in awk
View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #1 (permalink)  
Old 08-31-2004
raguramtgr raguramtgr is offline
Registered User
  
 

Join Date: Jan 2004
Location: chennai, india
Posts: 47
Query in awk

file "batsmen" contains

Bradman;Australia;52;6996
Gavaskar;India;124;10122
Sobers;West;Indies;93;8032
Border;Australia;109;8075
Miandad;Pakistan;97;7121
Gower;England;94;7023
Boycott;England;108;8114

My awk script contains

awk '{FS=";"}
{len=length($1)};
{printf("%s %d\n"), $1, len}' batsmen

when i run the script i get an output like this

Bradman;Australia;52;6996 25
Gavaskar 8
Sobers 6
Border 6
Miandad 7
Gower 5
Boycott 7

i need the first row as "Bradman 7" but it is not working with this script.

What should i do to rectify this. More over when to use "BEGIN & END"

replies appreciated.

raguram r