Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Using AWK to pad empty fields

Using AWK to pad empty fields

Using AWK to pad empty fields

Hi All,
I am using AWK to parse lines of a logfile to extract pertinent data but have hit a problem that I'm not even sure I can solve with AWK.

Within the logline I have three bracketed sections; the first of which are the fixed fields. i.e There are always seven values. The second and third sections are the corresponding values to each fixed value. So in the logline example below,
First fixed value 1 has values ranging from 1.2 to 1.4 (first fields in sections two and three) and so on.
Second fixed value 2 has values ranging from 1.3 to 1.5.
Third fixed value 3 has values ranging from 1.4 to 1.6.


My issue is that i need to pad the second and third fields with 0.0 if no match to the fixed fields in section 1.

So, using the above, [1,2,3,5,10,15,20],[1.2,1.3,1.4,0.0,0.0,0.0,0.0],[1.4,1.5,1.6,0.0,0.0,0.0,0.0]

Clearly i'm not an expert and to be honest cannot even think of a way to do it, apart from possibly using a for loop and an associative array for section one and pumping 0.0 for any null array values.

Any help or pointers in the right direction would be most appreciated.


RE: Using AWK to pad empty fields

Thank you PHV, thats a great solution. Let me try it out.

Really appreciate the help.

RE: Using AWK to pad empty fields

Works perfectly, thanks again PHV.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close