Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Location: Northeastern Michigan, where Carhartt is a Designer Label
Distribution: Slackware 32- & 64-bit Stable
Posts: 3,541
Rep:
You can do a fixed-length field for the account name using printf() formatting.
messagebus seems to be the longest (at 10 characters) so you'd want to change your print to, say, printf("%10s\t%s\n"),$1, $7; (and remove the BEGIN{OFS="\t";} because the tab is in the format); that forces the first field to be 10 characters wide, left justified (you could also make it right justified if you want).
You can do a fixed-length field for the account name using printf() formatting.
messagebus seems to be the longest (at 10 characters) so you'd want to change your print to, say, printf("%10s\t%s\n"),$1, $7; (and remove the BEGIN{OFS="\t";} because the tab is in the format); that forces the first field to be 10 characters wide, left justified (you could also make it right justified if you want).
"Tab" is an ascii character just like any other, taking up one byte in a text file. It's up to the programs that display the text to decide how wide the tab appears visually. Awk doesn't do any displaying, it just processes the ascii value, so it has nothing to do with how "wide" the tab is.
Also, the tab display width calculation is a complex one that depends on the font width as well as the number of "spaces" it's set for, which is why the exact same text file can have completely different tab alignments under different fonts or programs. If you want text to always line up, you have to use physical spaces (and ideally a monospace display font).
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.