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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

awk substr adds extra spaces

Status
Not open for further replies.

ptmcs

Technical User
Oct 1, 2004
38
GB
hi,

The following awk works 'mostly ok',
except extra spaces are added by awk.
Does anybody know how to stop it from doing that?

cat $filein | awk '{print \
"|", substr($0,15, 2 ), \
"|", substr($0,72, 4 ), \
"|", substr($0,230, 80), \
"|", substr($0,856, 7 ) \
}'>fileout

eg:

| 02 | CHIL | |

Cheers

 
Space is the default output separator, which will be placed wherever you have a comma in the print command. If you just take the commas out it should do what you expect (they aren't required).

Annihilannic.
 
Thanks! that's done the trick...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top