Check if folder is a mounted remote filesystem
As Stephane says "there is no universal Unix answer to that".
The best solution I have found to my question:
df -P -T /my/path/to/folder | tail -n +2 | awk '{print $2}'
will return the filesystem type, for example: nfs
or ext3
.
The -T
option is not standard, so it may not work on other Unix/Linux systems...
According to Gilles' comment below: "This works on any non-embedded Linux, but not on BusyBox, *BSD, etc."
You could use GNU stat
.
%m
to find out the mountpoint.
$ stat --format=%m /usr/src/linux
/usr/src
%T
(in file-system mode) to find out the name of the file system.
$ stat --file-system --format=%T /usr/src/linux
reiserfs
Thus you know that /usr/src/linux
, on my system, is stored in a filesystem that is mounted on /usr/src
and has the filesystem type reiserfs
.
Also refer to man stat
for further reference. It's a very versatile command, useful almost always when you need info about files and don't want to fall back to grep | awk
wardness.
mount -l
and use grep
, sed
, or awk
to find the line that refers to the directory in question.