如何在linux df命令中选择特定的列 [英] How to select a particular column in linux df command

查看:769
本文介绍了如何在linux df命令中选择特定的列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试收集有关不同服务器上剩余空间量的信息.因此,当我执行df -k时,我得到的输出为:

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-blocks    Used     Avail Capacity  Mounted on
/dev/ad1s1f   125925198 2568970 113282214     2%    /builds

有时输出为:

Filesystem           1K-blocks      Used Available Use% Mounted on
10.102.1.123:/storage/disk1/build
                     10735331328 10597534720 137796608  99% /buildbackup

现在,我想获取可用磁盘空间上的数据.因此,让我知道如何从特定列中获取数据.

Now I want to fetch data on the disk space available. So let me know how to fetch data from a particular column.

推荐答案

例如,您可以说:

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

来自man df:

-输出[= FIELD_LIST]

使用FIELD_LIST定义的输出格式,或者在出现以下情况时打印所有字段 省略了FIELD_LIST.

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

...

FIELD_LIST是要包括的列的逗号分隔列表.有效的 字段名称为:源","fstype",全部",使用",可用", "ipcent","size","used","avail","pcent"和"target"(请参阅​​信息 页).

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

-直接

显示文件而不是挂载点的统计信息

show statistics for a file instead of mount point

测试

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

这篇关于如何在linux df命令中选择特定的列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆