0

I am attempting to use | column -t at eh end of a df command in a simple script, and I keep getting an error.

Here is my script:

#!/bin/sh
CMD=`df -Pi | column -t`
echo $CMD

this is the output that happens when I run it:

Filesystem Inodes IUsed IFree IUse% Mounted on /dev/mapper/rootvg-root 327680 149683 177997 46% / tmpfs 3851091 1 3851090 1% /dev/shm /dev/sda1 99568 62 99506 1% /boot /dev/mapper/rootvg-home 131072 1457 129615 2% /home /dev/mapper/rootvg-tmp 131072 51 131021 1% /tmp /dev/mapper/rootvg-local 65536 97 65439 1% /usr/local /dev/mapper/rootvg-var 131072 5359 125713 5% /var /dev/mapper/rootvg-log 132464 1535 130929 2% /var/log /dev/mapper/rootvg-audit 65536 16 65520 1% /var/log/audit /dev/mapper/optvg-opt 3276800 216348 3060452 7% /opt

It's all 1 big blob. I'm assuming I'm missing some wrapping characters to the actual command, but I haven't been able to find anything.

This is the output I am looking for from a script:

Filesystem                Inodes   IUsed   IFree    IUse%  Mounted         on
/dev/mapper/rootvg-root   327680   149683  177997   46%    /
tmpfs                     3851091  1       3851090  1%     /dev/shm
/dev/sda1                 99568    62      99506    1%     /boot
/dev/mapper/rootvg-home   131072   1457    129615   2%     /home
/dev/mapper/rootvg-tmp    131072   51      131021   1%     /tmp
/dev/mapper/rootvg-local  65536    97      65439    1%     /usr/local
/dev/mapper/rootvg-var    131072   5359    125713   5%     /var
/dev/mapper/rootvg-log    132464   1535    130929   2%     /var/log
/dev/mapper/rootvg-audit  65536    16      65520    1%     /var/log/audit
/dev/mapper/optvg-opt     3276800  216353  3060447  7%     /opt
theGlitchKing
  • 87
  • 1
  • 9

2 Answers2

1

you need to wrap your echo in double quotations. So it respects the spaces,newlines, etc.

echo "$CMD"
Matias Barrios
  • 4,674
  • 3
  • 22
  • 49
0

You are missing the pipe "|":

CMD=`df -Pi | column -t`
echo "$CMD"

But, something tells me this isn't what you wanted either.

keithpjolley
  • 2,089
  • 1
  • 17
  • 20