Article 52Y49 [SOLVED] AWK command help - need to format output into set columns - PLEASE HELP

[SOLVED] AWK command help - need to format output into set columns - PLEASE HELP

by
r34per
from LinuxQuestions.org on (#52Y49)
Hi All :)

Does anyone know how to organise the output of a command into a specific number of columns using 'awk' ?

I am trying to run the following command:

Code:lsblk | grep disk | awk ' { printf "%-11s %5s\t", $1,$4 } 'As you can see from the above command, I am listing the block devices, then grepping out only the disks and then trying to put that information into a readable format.

At the moment, when I run the above, I get it in the following format:

Code:sda 200G sdb 302G sdc 102G sdd 502GNow ordinarily this would be ok as it does bring it up as columns however my setup has 100's of disks and the amount of columns it shows on screen is dependant on how big you console window is. How can I set it to only show 10 fields per row with equal spacing? so something like:

Code:sda 200G sdb 300G sdc 100G etc etcCan anyone help?

Thanks in advance :)latest?d=yIl2AUoC8zA latest?i=S2VpD6GREJI:ndosRMGdOhw:F7zBnMy latest?i=S2VpD6GREJI:ndosRMGdOhw:V_sGLiP latest?d=qj6IDK7rITs latest?i=S2VpD6GREJI:ndosRMGdOhw:gIN9vFwS2VpD6GREJI
External Content
Source RSS or Atom Feed
Feed Location https://feeds.feedburner.com/linuxquestions/latest
Feed Title LinuxQuestions.org
Feed Link https://www.linuxquestions.org/questions/
Reply 0 comments