Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.debian.user > #188319
| From | peter@easthope.ca |
|---|---|
| Newsgroups | linux.debian.user |
| Subject | bash usage. |
| Date | 2017-10-26 03:20 +0200 |
| Message-ID | <uEEZX-7hA-3@gated-at.bofh.it> (permalink) |
| Organization | linux.* mail to news gateway |
PROBLEM
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/.
ATTEMPTED SOLUTION
Create testdir and execute this script.
#!/bin/bash
# Demonstrate use of "mountpoint" in a script to determine
# whether a directory has a device mounted on it.
#
WorkingDirectory=/home/peter/testdir
if [ mountpoint $WorkingDirectory ]
then
echo A volume is mounted on $WorkingDirectory.
else
echo Nothing mounted on $WorkingDirectory.
fi
This is my result.
$ ./testscript
./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
Back to linux.debian.user | Previous | Next — Next in thread | Find similar | Unroll thread
bash usage. peter@easthope.ca - 2017-10-26 03:20 +0200
Re: bash usage. Roberto C. Sánchez <roberto@debian.org> - 2017-10-26 03:30 +0200
Re: bash usage. Kushal Kumaran <kushal@locationd.net> - 2017-10-26 03:40 +0200
Re: bash usage. David Margerison <deltam@electrosonics.com.au> - 2017-10-26 08:20 +0200
Re: bash usage. Roberto C. Sánchez <roberto@debian.org> - 2017-10-26 13:10 +0200
Re: bash usage. David Margerison <deltam@electrosonics.com.au> - 2017-10-26 14:40 +0200
Re: bash usage. Roberto C. Sánchez <roberto@debian.org> - 2017-10-26 14:40 +0200
Re: bash usage. Jude DaShiell <jdashiel@panix.com> - 2017-10-27 00:10 +0200
Unidentified subject! peter@easthope.ca - 2017-11-04 19:40 +0100
csiph-web