例8:只打印本地文件系统磁盘的使用情况
假设网络文件系统也挂载在 Linux 上,但我们只想显示本地文件系统的信息,这可以通过使用 df 命令的 -l 选项来实现。

只打印本地文件系统:
[root@linux-world ~] # df -Thl Filesystem Type Size Used Avail Use% Mounted on /dev/mapper/vg00-root ext4 17G 791M 15G 6% / devtmpfs devtmpfs 754M 0 754M 0% /dev tmpfs tmpfs 760M 0 760M 0% /dev/shm tmpfs tmpfs 760M 8.4M 752M 2% /run tmpfs tmpfs 760M 0 760M 0% /sys/fs/cgroup /dev/mapper/vg00-home ext4 15G 41M 14G 1% /home /dev/sda1 ext3 477M 62M 387M 14% /boot /dev/mapper/vg00-var ext3 9.5G 105M 8.9G 2% /var /dev/mapper/vg00-sap ext3 15G 37M 14G 1% /sap [root@linux-world ~] #
例9:打印特定文件系统类型的磁盘使用情况
-t 选项在 df 命令中用来打印特定文件系统类型的信息,用 -t 指定文件系统的类型,如下所示:
对于 ext4 :
[root@linux-world ~] # df -t ext4 Filesystem 1K-blocks Used Available Use% Mounted on /dev/mapper/vg00-root 17003304 809492 15307028 6% / /dev/mapper/vg00-home 14987616 41000 14162232 1% /home [root@linux-world ~] #
对于 nfs4 :
[root@linux-world ~] # df -t nfs4 Filesystem 1K-blocks Used Available Use% Mounted on 192.168.1.5:/opensuse 301545472 266833920 19371008 94% /data [root@linux-world ~] #
例10:使用 -x 选项排除特定的文件系统类型
-x 或 –exclude-type 在 df 命令中用来在输出中排出某些文件系统类型。
假设我们想打印除 ext3 外所有的文件系统。
[root@linux-world ~] # df -x ext3 Filesystem 1K-blocks Used Available Use% Mounted on /dev/mapper/vg00-root 17003304 809492 15307028 6% / devtmpfs 771876 0 771876 0% /dev tmpfs 777928 0 777928 0% /dev/shm tmpfs 777928 8540 769388 2% /run tmpfs 777928 0 777928 0% /sys/fs/cgroup /dev/mapper/vg00-home 14987616 41000 14162232 1% /home 192.168.1.5:/opensuse 301545472 266834944 19369984 94% /data [root@linux-world ~] #
例11:在 df 命令的输出中只打印特定的字段
-output={field_name1,field_name2...} 选项用于显示 df 命令某些字段的输出。
可用的字段名有: source, fstype, itotal, iused, iavail, ipcent, size, used, avail, pcent 和 target
[root@linux-world ~] # df --output=fstype,size,iused Type 1K-blocks IUsed ext4 17003304 22275 devtmpfs 771876 357 tmpfs 777928 1 tmpfs 777928 423 tmpfs 777928 13 ext4 14987616 15 ext3 487652 337 ext3 9948012 1373 ext3 14987656 11 nfs4 301545472 451099 [root@linux-world ~] #










