How to find out (in sh) whether a directory is installed via NFS

df -t nfs $ directory

returns two lines of output if the directory is installed on NFS and one line if it is not.

Some versions of df give an exit status of 1 if it is not mounted by NFS, but GNU coreutils 5.3.0 does not ...

if [ `df -t nfs . | wc -l` = 2 ]; 

Feels inelegant, and colleagues say that he doesn’t check errors enough. Is there a better way to do this?

+5
source share
2 answers

Duplicate question How to determine if a directory is an NFS mount point in shellscript . Short answer, use the command stat.

+3
source

, mtab flatfile, strace , df . , /proc/mounts, Linux.

0

All Articles