How to select a particular column in linux df command

前端 未结 2 1736
生来不讨喜
生来不讨喜 2020-12-06 07:50

I am trying to collect information on the amount of space left on different servers. So when I execute df -k i get output as:

Filesystem  1024-         


        
2条回答
  •  没有蜡笔的小新
    2020-12-06 08:37

    You can for example say:

    df --output=source,avail
    

    Or as commented by Tim Bunce, you can use --direct to prevent the long filesystem name make the line split in two. This will show the filesystem as -.

    From man df:

    --output[=FIELD_LIST]

    use the output format defined by FIELD_LIST, or print all fields if FIELD_LIST is omitted.

    ...

    FIELD_LIST is a comma-separated list of columns to be included. Valid field names are: 'source', 'fstype', 'itotal', 'iused', 'iavail', 'ipcent', 'size', 'used', 'avail', 'pcent' and 'target' (see info page).

    --direct

    show statistics for a file instead of mount point

    Test

    $ df --output=source,avail
    Filesystem               Avail
    /dev/sda7            321675536
    

提交回复
热议问题