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<>

You could use field width specifies in the printf:

printf "%3d   %15s   %s\n" 4
printf "%3d   %15s   %s\n" 2

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`  \

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...


JP Vossen, CISSP            |:::======|
My Account, My Opinions     |=========|
"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         --
Announcements -
General Discussion  --