If this is your first visit, be sure to check out the FAQ by clicking the link above.
You may have to register before you can post: click the register link above to proceed.
To start viewing messages, select the forum that you want to visit from the selection below.
I am trying make an awk script that does a command, looks at $10. If $10 does not have a value, print $9, else print $10. I think this is probably fairly easy, but I am getting lost doing this. Can somebody please show me how to do this?
Originally posted by aigles
Don't use printf because the first argument is a format.
If the printed field ($9 or $10) contains a valid directive (eg %d) awk will failed.
Code:
print ($10 ? $10 : $9);
Uff-da! Good catch, sorry. I still think you just need to add the format string and then it should work fine, or at least it does on my awk.