How to test if a given path is a mount point

后端 未结 10 825
-上瘾入骨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:08

    for mountedPath in `mount | cut -d ' ' -f 3`; do
        if [ "${mountedPath}" == "${wantedPath}" ]; then
            exit 0
        fi
    done
    exit 1
    

提交回复
热议问题