How can I tell if a file is on a remote filesystem with Perl?

后端 未结 5 1123
梦毁少年i
梦毁少年i 2021-02-03 11:01

Is there a quick-and-dirty way to tell programmatically, in shell script or in Perl, whether a path is located on a remote filesystem (nfs or the like) or a local one? Or is the

5条回答
  •  -上瘾入骨i
    2021-02-03 11:34

    You can use "df -T" to get the filesystem type for the directory, or use the -t option to limit reporting to specific types (like nfs) and if it comes back with "no file systems processed", then it's not one of the ones you're looking for.

    df -T $dir | tail -1 | awk '{print $2;}'
    

提交回复
热议问题