But if I put in print statements to print the records, the record number, and number of fields prior to the first pattern match and set the Field separator (hard coded ) within the variable/constants definitions the script will print all of individual records in the file along with accurate record numbers and field counts.
Also tried with just printing the first field (print $1) as well as a substring of the first 4 characters, that, for the most part worked correctly also
-----Original Message-----
From: MIDRANGE-L [mailto:midrange-l-bounces@xxxxxxxxxxxx] On Behalf Of Buck Calabro
Sent: Wednesday, July 20, 2016 11:41 AM
To: midrange-l@xxxxxxxxxxxx
Subject: Re: Awk script running in QShell
On 7/20/2016 11:41 AM, Fuchs, James M wrote:
Also based on the fact that the pattern match works on the first pattern /^ISA/ but not any of the subsequent patterns.
That tells me that the record separator isn't being recognised; that AWK thinks the whole file is one big record, and that the /^ISA/ pattern is grabbing the substrings and moving on. But since the subsequent patterns are not at the beginning of the record (like /^TA1/) then AWK doesn't find any of those patterns and thus cannot perform the related action.
Have a look at your input file and make sure it has a record separator that matches the RS (record separator) that is being set. Assuming here that AWK is invoked with -f (for the input file) and that the first 2 parameters are for documentation purposes rather than actual input and output.
--
--buck
Visit wiki.midrange.com and register for an account. Edit a page that helps you, and because it's public, you'll help someone else, too!
--
This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing list To post a message email: MIDRANGE-L@xxxxxxxxxxxx To subscribe, unsubscribe, or change list options,
visit:
http://lists.midrange.com/mailman/listinfo/midrange-l
or email: MIDRANGE-L-request@xxxxxxxxxxxx Before posting, please take a moment to review the archives at
http://archive.midrange.com/midrange-l.
Please contact support@xxxxxxxxxxxx for any subscription related questions.
________________________________
This communication may contain confidential Protected Health Information. This information is intended only for the use of the individual or entity to which it is addressed. The authorized recipient of this information is prohibited from disclosing this information to any other party unless required to do so by law or regulation and is required to destroy the information after its stated need has been fulfilled.
If you are not the intended recipient, you are hereby notified that any disclosure, copying, distribution, or action taken in reliance on the contents of these documents is strictly prohibited by federal law. If you have received this information in error, please notify the sender immediately and arrange for the return or destruction of these documents.
As an Amazon Associate we earn from qualifying purchases.