7.13. Odds and Ends

Some data, read in from tape or from a spreadsheet, may not have obvious field separators, but the data does have fixed-width columns. To preprocess this type of data, the substr function is useful. (The files in this section are found on the CD in directory chap07/OddsAnd-Ends.)

7.13.1. Fixed Fields

In the following example, the fields are of a fixed width, but are not separated by a field separator. The substr function is used to create fields. For gawk, see the "The FIELDWIDTHS Variable" on page 241.

Example 7.85.
% cat fixed
						031291ax5633(408)987–0124
						021589bg2435(415)866–1345
						122490de1237(916)933–1234
						010187ax3458(408)264–2546
						092491bd9923(415)134–8900
						112990bg4567(803)234–1456
						070489qr3455(415)899–1426

% awk '{printf ...

Get Linux Shells by Example now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.