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

后端 未结 5 1116
梦毁少年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条回答
  •  隐瞒了意图╮
    2021-02-03 11:13

    If you use df on a directory to get info only of the device it resides in, e.g. for the current directory:

    df .
    

    Then, you can just parse the output, e.g.

    df . | tail -1 | awk '{print $1}'
    

    to get the device name.

提交回复
热议问题