we have linux rhel machine 7.2 with the following folders under
/kafka/topics
drwxr-xr-x 2 root kafka 141 May 11 17:19 bgol.ase.fgt.dad3-1
drwxr-xr-x 2 root kafka 141 May 11 17:19 bgol.ase.fgt.dad3-10
drwxr-xr-x 2 root kafka 141 May 11 17:19 bgol.ase.fgt.dad3-100
drwxr-xr-x 2 root kafka 141 May 11 17:19 bgol.ase.fgt.dad3-103
drwxr-xr-x 2 root kafka 141 May 11 17:19 bgol.ase.fgt.dad3-106
drwxr-xr-x 2 root kafka 141 May 11 17:19 bgol.ase.fgt.dad3-109
drwxr-xr-x 2 root kafka 141 May 11 17:19 bgol.ase.fgt.dad3-112
drwxr-xr-x 2 root kafka 141 May 11 17:19 bgol.ase.fgt.dad3-115
drwxr-xr-x 2 root kafka 141 May 11 17:19 bgol.ase.fgt.dad3-118
drwxr-xr-x 2 root kafka 141 May 11 17:19 bgol.ase.fgt.dad3-121
drwxr-xr-x 2 root kafka 141 May 11 17:19 bgol.ase.fgt.dad3-124
drwxr-xr-x 2 root kafka 141 May 11 17:19 bgol.ase.fgt.dad3-127
drwxr-xr-x 2 root kafka 141 May 11 17:19 bgol.ase.fgt.dad3-13
.
.
.
we want to delete all this topics with names -
bgol.ase.fgt.dad3
by using variable as ,
topic=bgol.ase.fgt.dad3
find /kafka/topics -name "$topic*" -exec rm -rf "{}" \;
but I feel the above approach isn't so elegant , since we want to set this approach in bash script
I will appreciate to get other suggestion to delete the folders , when using variable as $topic