How do I determine if a directory is a mounted NFS mount point in shellscript

时光毁灭记忆、已成空白 提交于 2020-01-10 08:49:20

问题


I want to write a sh/bash script that can determine whether a particular directory is a mount point for an NFS filesystem.

eg something like

$ mkdir localdir
$ mkdir remotedir
$ mount host:/share ./remotedir
$ classify_dirs.sh
 -->  localdir is local
 -->  remotedir is an NFS mount point

回答1:


This question is effectively a dup of how-can-i-tell-if-a-file-is-on-a-remote-filesystem-with-perl

The short answer is to use the stat command

eg

$ stat -f -L -c %T localdir
ext2/ext3
$ stat -f -L -c %T remotedir
nfs

Then a directory is an NFS mount point if its type is 'nfs' and its parent directory isn't.



来源:https://stackoverflow.com/questions/460047/how-do-i-determine-if-a-directory-is-a-mounted-nfs-mount-point-in-shellscript

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!