Re: bash usage.
-----BEGIN PGP SIGNED MESSAGE-----
On Sun, Nov 05, 2017 at 08:31:00AM +1100, David Margerison wrote:
> On 5 November 2017 at 04:55, <firstname.lastname@example.org> wrote:
> > What about checking whether the
> > filesystem of a specific device is mounted at that directory? Can
> > that be checked easily?
> It can be done by inspecting the output of the 'mount' command.
> But keep in mind that the detail of this output may not be stable
> between versions of mount, or other factors that might change
> its content, such as releases of operating systems.
> Demo example from an interactive bash command line on this PC:
> $ devname=/dev/sda6 ; dirname=/mnt/p/A ; if mount | grep -q --
> "$devname on $dirname" ; then echo "$devname is mounted on $dirname" ;
> /dev/sda6 is mounted on /mnt/p/A
Note that the mount(8) man page recommends findmnt(8) for script
usage. Findmnt is util-linux, so whether you want to use it or
not will depend a bit on your portability needs.
Parsing mount output robustly is, of course, always a good exercise.
- -- tomás
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.12 (GNU/Linux)
-----END PGP SIGNATURE-----