JP Vossen on 23 May 2013 13:48:14 -0700 |
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
Re: [PLUG] 2013-05-21 PLUG W follow-up |
Date: Thu, 23 May 2013 10:00:04 -0400 From: Frank Szczerba<frank@szczerba.net> You could use field width specifies in the printf: printf "%3d %15s %s\n" 4 10.11.12.13 dns.name.one printf "%3d %15s %s\n" 2 207.111.106.151 yet.another.name
That was my thought too.Note you can sometimes get fancy and do away with temp variables if the output is intended to be a single line. Like:
printf "%3d %15s %s\n" \ $(foo) \ `bar` \ $(baz)Where `` and $() are the command substitution operators [1], I prefer the POSIX $() one. And foo, bar, and baz are some one-liners or whatever that return just the bit of data you want in that slot on that line.
It depends. Do whatever is easier to read and maintain...[1] http://www.bashcookbook.com/bashinfo/source/bash-4.2/doc/bashref.html#SEC33
Later, JP ----------------------------|:::======|------------------------------- JP Vossen, CISSP |:::======| http://bashcookbook.com/ My Account, My Opinions |=========| http://www.jpsdomain.org/ ----------------------------|=========|------------------------------- "Microsoft Tax" = the additional hardware & yearly fees for the add-on software required to protect Windows from its own poorly designed and implemented self, while the overhead incidentally flattens Moore's Law. ___________________________________________________________________________ Philadelphia Linux Users Group -- http://www.phillylinux.org Announcements - http://lists.phillylinux.org/mailman/listinfo/plug-announce General Discussion -- http://lists.phillylinux.org/mailman/listinfo/plug