Bug 10955

Summary: gawk fails on first record if using FS other than default
Product: [Retired] Red Hat Linux Reporter: jerry cloe <jerry>
Component: gawkAssignee: David Lawrence <dkl>
Status: CLOSED NOTABUG QA Contact:
Severity: high Docs Contact:
Priority: medium    
Version: 6.2CC: lynn
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2000-05-18 14:43:41 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Description jerry cloe 2000-04-21 04:24:24 UTC
gawk fails on first record (remaining records are OK) if using an FS value
of anything but the default (of space).  I have generated input files and
tested with a variety of FS values and the first record ALWAYS returns the
entire record as $1 and doesn't break it down into the appropriate
fields.  Remaining records return as expected.  First record only $1 has a
value (of the whole record) and remaining fields are null.

I can duplicate this error under redhat 5.2, 6.1 and 6.2, and using a
variety of different FS values, including ":" (documented below), "/", "a"
and several other values.

Example:

input file:
cat /etc/passwd
root:x:0:0:root:/root:/bin/bash
bin:x:1:1:bin:/bin:
daemon:x:2:2:daemon:/sbin:

looking for first record:
cat /etc/passwd | gawk '{FS=":"}{print $1}'
root:x:0:0:root:/root:/bin/bash
bin
daemon

looking for 5th record:
cat /etc/passwd | gawk '{FS=":"}{print $5}'
<<--this field returned nothing except an output record seperator,
  --I would have expected the word "root"
bin
daemon

Comment 1 jerry cloe 2000-04-22 06:45:59 UTC
In my examples, I meant to say "looking for first field" and "looking for 5th
field" rather than record...  sorry for any confusion

Comment 2 Florian La Roche 2000-05-18 14:43:59 UTC
use awk -F: '{ print $1 }'