I am in the middle of writing a bash script, I have multiple subfolders in a certain directory, I want to list the names of the subfolders and read the results into an array omitting a certain single folder called 'cmmdm' from the results. Once I have read the names into the array I want to generate a menu with each submenu name as a choice which I will then perform a function on the given subfolder depending on which choice the user makes.
EDIT: sorry should have added my initial code:
#!/bin/bash
# - create array
declare -a CDARRAY
# - set 0 to exit in prep for menu
CDARRAY[0]=exit
# - create a counter to use in while loop
count=1
# - while loop to itterate through folder and add each folder except cmmdm into array
ls -d /home/nginx/domains/* | {
while read CMMDOMAIN ; do
if [ $CMMDOMAIN != "/home/nginx/domains/cmmdm" ]
then
$CDARRAY[$count]=$CMMDOMAIN
echo $CDARRAY[$count]
count=$[count + 1]
fi
done
}
This does go through the folders and does ignore 'cmmdm' however my code to add the variable CMMDOMAIN to the array is wrong. I have never written a script in bash before so I think probably I've gotten the syntax wrong or missing some braces or something