我有一个安装在特定目录上的 tmpfs 文件系统。我想写一个 shell 脚本来检查 tmpfs 文件系统是否已经挂载到目录中。
最佳答案
有一个专门用于此的工具:mountpoint(1)
if mountpoint -q "$directory" ; then
echo it is a mounted mountpoint
else
echo it is not a mounted mountpoint
fi
而且您甚至不必刮掉琴弦!
请注意,我在 Debian 的 initscripts 包中找到了这个工具。它在其他地方的可用性如何,我无法评论。
关于用于了解文件系统是否已挂载的 Shell 脚本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53390072/