Operating System - HP-UX
1833159 Members
3163 Online
110051 Solutions
New Discussion

Why blank lines in AWK output

 
SOLVED
Go to solution
Mark Cafferkey
Occasional Advisor

Why blank lines in AWK output

I am formatting an audit record and manage to retrieve what I want by changing the FS and NR variables but I end up with hundreds of blank lines for each record in the formatted output. Anyone have any ideas.
TIA
7 REPLIES 7
Volker Borowski
Honored Contributor

Re: Why blank lines in AWK output

What did you select as a FS ?

Standard is "whitespace", which includes NL (newline).
May be you should add NL to your modified FS list ?

Volker
James R. Ferguson
Acclaimed Contributor

Re: Why blank lines in AWK output

Hi Mark:

Posting your script and some sample inout data would be helpful here.

...JRF...
Mark Cafferkey
Occasional Advisor

Re: Why blank lines in AWK output

Attachment contains the awk script part that contains problem and sample input file. The RS variable only seems to interpret 1 char. which explains why I'm getting a lot of spaces but I need to work on each record seperately.
Thanks again
Mark Cafferkey
Occasional Advisor

Re: Why blank lines in AWK output

Attachment contains the awk script part that contains problem and sample input file. The RS variable only seems to interpret 1 char. which explains why I'm getting a lot of spaces but I need to work on each record seperately.
Thanks again
Klaus Crusius
Trusted Contributor

Re: Why blank lines in AWK output

Hi,

you should probably not change RS and FS.
It would be easier if you could tell what you want to select from your input files.

Klaus

There is a live before death!
Volker Borowski
Honored Contributor
Solution

Re: Why blank lines in AWK output

How about getting rid of the spaces, if $1 is empty, and print only, if there is something to print ?

BEGIN {RS = "~";}
{ if ( $1 != "" )
{
print $1
print $2
print $4
print $14
print $15
}
}


Volker
Mark Cafferkey
Occasional Advisor

Re: Why blank lines in AWK output

Spot on Volker,
Thanks a Mil.
Rgds
M