Categories
SysOps

How to display output of multiple commands using columns

Execute paste utility to merge lines using tab character as a delimiter, expand to convert tabs to spaces, and column to format input into multiple columns.

unifi controller
Two columns displaying the output of multiple commands

Display some necessary system information and some random Debian related epigram.

$ paste <(printf "Hostname: $(hostname)\nDate: $(LC_ALL=C date)"; printf "\n\n"; printf "Memory:\n"; head -4 /proc/meminfo) \
        <(printf "\n\n\n";LC_ALL=C df -h -x tmpfs -x devtmpfs) \
        <(printf "\n";fortune debian-hints | expand -t 8)  | \
  column -s $'\t' -tne
Hostname: milosz-XPS-13-9343                                                                       
Date: Tue Feb  6 21:39:04 CET 2018                                                                 Debian Hint #13: If you don't like the default options used in a Debian
                                                                                                   package, you can download the source and build a version which uses the
Memory:                             Filesystem                   Size  Used Avail Use% Mounted on  options you prefer. See http://www.debian.org/doc/FAQ/ch-pkg_basics.html
MemTotal:        8059088 kB         /dev/mapper/debian--vg-root  226G   90G  126G  42% /           (sections 6.13 and 6.14) for more information.
MemFree:         1338300 kB         /dev/sda2                    473M  336M  114M  75% /boot       
MemAvailable:    3353428 kB         /dev/sda1                    511M  4.7M  507M   1% /boot/efi   However, bear in mind that most options in most packages can be configured
Buffers:          233632 kB                                                                        at runtime, and do not require recompiling the package.

Display some necessary system information and fantastic ASCII art.

$ paste <(fortune mario.arteascii | expand -t 8) \
        <(printf "Hostname: $(hostname)\nDate: $(LC_ALL=C date)"; printf "\n\n"; printf "Memory:\n"; head -4 /proc/meminfo; printf "\n\n";LC_ALL=C df -h -x tmpfs -x devtmpfs) | \
  column -s $'\t' -tne
                                             Hostname: milosz-XPS-13-9343
             ..ooooox.                       Date: Tue Feb  6 22:22:49 CET 2018
        ..ooo@@@XXX%xx..                     
     ..oo@@XXX&x&xxx...                      Memory:
   .o@XX%%xx..                   ...         MemTotal:        8059088 kB
   o@X%x.                    ..oXXXoooo.     MemFree:          404848 kB
 .@X%x.                  ..o@^^      ^^@X.   MemAvailable:    2913868 kB
.ooo@@@@@@@ooo..      ..o@@^           @X%   Buffers:          242820 kB
o@@^^^     ^^^@@@ooo.oo@@^   *          %x.  
.o@          *   ^.  .                  .%^  
 .o.            .o@o o@.  .. oox.     .X%.   Filesystem                   Size  Used Avail Use% Mounted on
 .@x     .    %xxX@@   @o.     ^^Xxxx@@@^    /dev/mapper/debian--vg-root  226G   90G  125G  42% /
  .@  .xxx     .o@@^   ^@%%o..   .XX@@^      /dev/sda2                    473M  336M  114M  75% /boot
   .@@XX%      .x%@   .  @xxo^..             /dev/sda1                    511M  4.7M  507M   1% /boot/efi
     ^XX%%^  .@@X %  XXx @@^x%..             
            .o@@XX%xx.. ^^XX%%xx...          
           .oXXxx...                         
           .ooX@@@xxoo..                     
          .x%. .xxx.@Xx..                    
          .x^  ^X^ .o@Xx.                    
           ^    '   .o@x                     
           '          ^.                     
kalev kaarna - benkalev at ut.ee             

There are at least a couple of possible use cases involving this method, mostly informative ones.