AWK record length fix

Hi Friends,

Need some help in AWK.

Working on AIX 5

Have been trying the following functionality to make the record length fixed:

if( length(record) < 300 )
   {
    printf("%-300s\n", record);
   }

In my opinion it will apply some fillers in the end.

Its is not making any changes to length (say input record length is 200 its coming out to be 200 and not 300)

Could any body please give some other option

Thanks in advance
Kanu

I suspect that the method you are using the test the length is at fault, not awk. How are you doing it?

Try this:

if( length(record) < 300 )
   {
    printf("%-300s:\n", record);
   }

What result to you get now?

thanks for the reply Johnson,

you piece of change is also not producing the desired o/p.:frowning:

Any other suggestion is most welcome.

regards
Kanu

It adds so many spaces until the number of characters per record is reached.
You should open your file with vi and set following option:

:set list

It will show the $ for the end of the lines is at position 300. How did you check it's not 300?

Tested with awk that comes with AIX 5.3.

My only suggestion is to answer the questions I asked. It isn't possible to tell what's wrong if you don't provide enough information.

How are you capturing the output from awk?

How are you testing the length?

What result do you get after making the change I suggested?