【发布时间】:2010-10-02 09:10:48
【问题描述】:
我想编写一个 sh/bash 脚本,它可以确定特定目录是否是 NFS 文件系统的挂载点。
比如
$ mkdir localdir
$ mkdir remotedir
$ mount host:/share ./remotedir
$ classify_dirs.sh
--> localdir is local
--> remotedir is an NFS mount point
【问题讨论】:
我想编写一个 sh/bash 脚本,它可以确定特定目录是否是 NFS 文件系统的挂载点。
比如
$ mkdir localdir
$ mkdir remotedir
$ mount host:/share ./remotedir
$ classify_dirs.sh
--> localdir is local
--> remotedir is an NFS mount point
【问题讨论】:
这个问题实际上是how-can-i-tell-if-a-file-is-on-a-remote-filesystem-with-perl的重复
简短的回答是使用stat 命令
例如
$ stat -f -L -c %T localdir
ext2/ext3
$ stat -f -L -c %T remotedir
nfs
如果一个目录的类型是 'nfs' 而它的父目录不是,那么它就是一个 NFS 挂载点。
【讨论】:
illegal option -- c。自撰写此答案以来,统计数据是否发生了重大变化?