我如何确定一个目录是shellscript里一个NFS挂载点 [英] How do I determine if a directory is an NFS mount point in shellscript

查看:163
本文介绍了我如何确定一个目录是shellscript里一个NFS挂载点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想写的sh / bash脚本,可以决定一个特定的目录是否是一个挂载点,一个NFS文件系统。

例如像

  $的mkdir LOCALDIR
$的mkdir remotedir
$安装主机:/股./remotedir
$ classify_dirs.sh
  - > LOCALDIR是本地的
  - > remotedir是NFS挂载点


解决方案

这问题是有效的<一个一个DUP href=\"http://stackoverflow.com/questions/296455/how-can-i-tell-if-a-file-is-on-a-remote-filesystem-with-perl\">how-can-i-tell-if-a-file-is-on-a-remote-filesystem-with-perl

简短的回答是使用统计命令

例如

  $统计-f -L -c%T LOCALDIR
EXT2 / EXT3
$统计-f -L -c%T remotedir
NFS

然后,目录是NFS挂载点如果它的类型是NFS和它的父目录不是。

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

解决方案

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.

这篇关于我如何确定一个目录是shellscript里一个NFS挂载点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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