Working with Record Files

Every large business that processes its own data works with record files. Record files contain lines of data that are either field delimited, called a variable-length record file, or each line of data is the same length and each data field is defined by string length and position, called a fixed-length record file. We will look at examples of each record file format type and methods of processing the files quickly and manipulating the data. I added this chapter to this second edition at the request of a co-worker at Coca-Cola Enterprises, Mark Sellers. Mark asked me one day for a quick way to add the name of the record file to the end of every record, or line, in the file. Mark's problem was that when he merged a bunch of record files together in a single file for batch processing, and the batch file had an error with a particular record, he had no idea which record file the record came from. We will look at methods to solve this problem and many others.

What Is a Record File?

A record file is an alphanumeric character flat file (text file) that contains one or more lines of data. Each separate line of data is called a record. A record is made up of different fields that contain the actual data. There are two types of record files:

  • Fixed-length record files are files with fixed column width with each data field residing within a specific character length and position within the record.
  • Variable-length record files are files where the individual ...

Get Mastering UNIX® Shell Scripting: Bash, Bourne, and Korn Shell Scripting for Programmers, System Administrators, and UNIX Gurus, Second Edition now with O’Reilly online learning.

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