Issue
I haven't had much luck finding the answer to my question. I would like to find the next logical empty mountpoint using the mountpoint command in Ubuntu. This will allow multiple occurrences of a script I am writing to automate some tasks.
#!/bin/bash
MNT="ewf"
COUNT=""
until mountpoint -q /mnt/"$MNT""$COUNT"
do
COUNT=$((COUNT+1))
echo "$MNT""$COUNT is a mountpoint"
done
echo "$MNT""$COUNT is not a mountpoint"
Where the loop would iterate through untill it found a empty mountpoint such as /mnt/ewf1. I've tried various possible solutions and this is the closest I think I have come. But I am unsure how to pass a statement as true or false without the usage of a boolean value in Bash.
The issue I have found with the above is the variable $COUNT is being declared as " " (space) so it is adding a character to /ewf prior to +1.
I am unsure how to correct it.
Solution
Change until mountpoint ...
to while mountpoint ...
. You want to skip entries that are mount points.
Answered By - Stephen Gildea