0

I am currently writing a script that makes mounting of LUKS devices easier. In the script I do have a default mountpoint name (

data
), – however, if a mountpoint like that already exists, I want to append a number to it, test again and so on, until I find a string that is not yet a mountpoint.

For example, I can list mountpoints like so:

lsblk -o MOUNTPOINTS
.

Lets assume the the output is:

/
/boot
/mnt/data
/mnt/data2
/mnt/data3
/var/lib/docker

My default mountpoint name is

data
. Now I want to get a valid new mountpoint name. In this case, this would be
data4
, because
data
,
data2
and
data3
already exist. Whats the easiest way to get a name that gets incremented like this? I assume I can do some awk magic maybe?