6

Input: df -k

Output:

Filesystem            kbytes    used   avail capacity  Mounted on
/dev/dsk/c0t0d0s0    10332220  443748 9785150     5%    /
/devices                   0       0       0     0%    /devices
ctfs                       0       0       0     0%    /system/contract
proc                       0       0       0     0%    /proc
mnttab                     0       0       0     0%    /etc/mnttab
swap                 45475864    1688 45474176     1%    /etc/svc/volatile
objfs                      0       0       0     0%    /system/object
sharefs                    0       0       0     0%    /etc/dfs/sharetab
/dev/dsk/c0t0d0s3    10332220 3513927 6714971    35%    /usr

I want to omit the 1st line Filesystem kbytes used avail capacity Mounted on from the output.

I used df -k | tail -n+2 in linux to get exactly what i wanted, but in SunOs I get

zenvo% df -k | tail -n+2
usage: tail [+/-[n][lbc][f]] [file]
   tail [+/-[n][l][r|f]] [file]

How can i achieve the Required output:

/dev/dsk/c0t0d0s0    10332220  443748 9785150     5%    /
/devices                   0       0       0     0%    /devices
ctfs                       0       0       0     0%    /system/contract
proc                       0       0       0     0%    /proc
mnttab                     0       0       0     0%    /etc/mnttab
swap                 45475864    1688 45474176     1%    /etc/svc/volatile
objfs                      0       0       0     0%    /system/object
sharefs                    0       0       0     0%    /etc/dfs/sharetab
/dev/dsk/c0t0d0s3    10332220 3513927 6714971    35%    /usr

Note: No. of rows might change

hsz
  • 148,279
  • 62
  • 259
  • 315
AabinGunz
  • 12,109
  • 54
  • 146
  • 218

4 Answers4

45

I know it's an old thread, but the shortest and the clearest of all:

df -k | sed 1d
Bart N
  • 995
  • 8
  • 7
4

I haven't used SunOS but using sed you should be able to delete the first line like this:

df -k | sed -e /Filesystem/d

edit: But you would have to be careful that the word Filesystem doesn't show up elsewhere in the output. A better solution would be:

df -k | sed -e /^Filesystem/d
wollw
  • 414
  • 2
  • 3
2

If you want to omit the first line of any result, you can use tail:

<command> | tail -n +2

So in your case:

df -k | tail -n +2

https://man7.org/linux/man-pages/man1/tail.1.html

ESP32
  • 8,089
  • 2
  • 40
  • 61
1

What about:

df -k | tail -$((`df -k | wc -l`-1))
hsz
  • 148,279
  • 62
  • 259
  • 315
  • shows some error, here is the output ` df -k | tail -$((`df -k | wc -l`-1)) Variable syntax` @wollw: solved my problem – AabinGunz Jul 04 '11 at 13:27