Given a storage device, /dev/GRN, and mount point, /home/peter/testdir/,
determine in a shell script whether /dev/GRN is mounted or something is
mounted on /home/peter/testdir/.
Create testdir and execute this script.
# Demonstrate use of "mountpoint" in a script to determine
# whether a directory has a device mounted on it.
if [ mountpoint $WorkingDirectory ]
echo A volume is mounted on $WorkingDirectory.
echo Nothing mounted on $WorkingDirectory.
This is my result.
./testscript: line 6: [: mountpoint: unary operator expected
Nothing mounted on /home/peter/testdir.
According to 'man mountpoint', it returns 0 if something is mounted.
So why the complaint from
if [ mountpoint $WorkingDirectory ] ?
Thanks, ... Peter E.
123456789 123456789 123456789 123456789 123456789 123456789 123456789
Tel: +1 360 639 0202 Pender Is.: +1 250 629 3757
http://easthope.ca/Peter.html Bcc: peter at easthope. ca