Bugzilla will be upgraded to version 5.0. The upgrade date is tentatively scheduled for 2 December 2018, pending final testing and feedback.
Bug 10955 - gawk fails on first record if using FS other than default
gawk fails on first record if using FS other than default
Product: Red Hat Linux
Classification: Retired
Component: gawk (Show other bugs)
All Linux
medium Severity high
: ---
: ---
Assigned To: David Lawrence
Depends On:
  Show dependency treegraph
Reported: 2000-04-21 00:24 EDT by jerry cloe
Modified: 2008-05-01 11:37 EDT (History)
1 user (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2000-05-18 10:43:41 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)

  None (edit)
Description jerry cloe 2000-04-21 00:24:24 EDT
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.


input file:
cat /etc/passwd

looking for first record:
cat /etc/passwd | gawk '{FS=":"}{print $1}'

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"
Comment 1 jerry cloe 2000-04-22 02:45:59 EDT
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 10:43:59 EDT
use awk -F: '{ print $1 }'

Note You need to log in before you can comment on or make changes to this bug.