[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: quick scripting 'is /P/Q mounted'



On 13/03/18 16:40, Mike McClain wrote:
> A while back, Pierre Gaston posted this little tidbit to quickly
> determine if my network is up:
>     [ "$(</sys/class/net/eth0/operstate)" = 'up' ]
> 
> Now I wonder if there is a similar file in /sys that would tell if
> anything is mounted on a particular directory. I've browsed /sys but
> not found what I'm looking for.
> 
> If my other computer is South40 and I want to mount South40's /docs
> on my /south40/docs/ directory I can do that. As one script calls
> another I want to know if I need to mount South40 without
> $( mount | grep 'south40/docs').

You could look at /proc/mounts, but that's similar to the output of mount.

Or if it's for a specific directory, and you can put something in it,
you can test for the existence of a special file in the directory.

Something like

[ -f /south40/docs/.flag ]

Richard


Attachment: signature.asc
Description: OpenPGP digital signature


Reply to: