How to test if a given path is a mount point

后端 未结 10 1007
-上瘾入骨i
-上瘾入骨i 2021-01-31 08:41

Suppose do you want test if /mnt/disk is a mount point in a shell script. How do you do this?

10条回答
  •  眼角桃花
    2021-01-31 09:00

    I discover that on my Fedora 7 there is a mountpoint command.

    From man mountpoint:

    NAME
           mountpoint - see if a directory is a mountpoint
    
    SYNOPSIS
           /bin/mountpoint [-q] [-d] /path/to/directory
           /bin/mountpoint -x /dev/device
    

    Apparently it come with the sysvinit package, I don't know if this command is available on other systems.

    [root@myhost~]# rpm -qf $(which mountpoint)
    sysvinit-2.86-17
    

提交回复
热议问题