Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Try this, replace "/foo/bar" with the path to your mount point, and the echos with additional desired behaviour.

(I'm assuming you're writing a bash script on a Linux system)

if grep -qs '/foo/bar' /proc/mounts; then

    echo "/foo/bar mounted"
else

    echo "/foo/bar not mounted"

    return 1 || exit 1
fi

Put these commands below the shebang but before the start of the script. I hope this helps you!

Edit: I added a crapload of newlines to better show the indentation and newlines required for the script to work. Sorry it's ugly



Consider applying for YC's Winter 2026 batch! Applications are open till Nov 10

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: