Reputation: 791
df -t nfs $directory
returns two lines of output if the directory is NFS-mounted and one line if it isn't.
Some versions of df give exit status 1 if it wasn't NFS-mounted, but GNU coreutils 5.3.0 doesn't ...
if [ `df -t nfs . | wc -l` = 2 ];
feels inelegant and colleagues say that it doesn't check sufficiently for errors. Is there a better way to do this?
Upvotes: 5
Views: 2574
Reputation: 72735
Duplicate question How do I determine if a directory is an NFS mount point in shellscript. Short answer, use the stat
command.
Upvotes: 3
Reputation: 1
You could always check mtab it keeps a record of all mounted filesystems in a flatfile, if you use strace and look that is all df does anyway. I suppose you could also use /proc/mounts if your running this in Linux.
Upvotes: 0