Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I set the appropriate number of tabs in an awk script? 1

Status
Not open for further replies.

johngiggs

Technical User
Oct 30, 2002
492
US
I have an awk script that I'm using to print out the columns of a file and I have the column width set to 60 for each:

printf ("%-60s %-60s\n", value1, value2)

That works fine, but in this case, I want the fields to be tabbed, but obviously with a longer line X number of tabs will not keep them aligned.

Ex. ThisIsAReallyLongString
ButThisIsNot

If I append 2 tabs, "ButThisIsNot" won't align with "ThisIsAReallyLongString".

How can I determine the correct number of tabs so the columns align? i.e. it would need to add 3 tabs in some cases, 2 tabs in others, etc.

Any help would be greatly appreciated.

Thanks,

John
 
Why not simply pipe the output of awk to pr -i ?

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top