My script goes as follow:
- Search for all the isos available under some path
- Compare the isos names to a list in a file
- Return only the matches
To abreviate, the code is:
isos_found=() # here we save the isos
isos_search=<find isos>
mapfile -t supported_isos < supported_systems # see below
for iso in "${isos_search[@]}" ; do
[[ "${supported_isos[@]}" =~ "$(basename "$iso")" ]] && isos_found+=("$iso")
done
Where supported_systems is a file with the contents:
clonezilla-live-2.6.1-25-amd64.iso
debian-live-10.0.0-amd64-xfce+nonfree.iso
linuxmint-19.1-cinnamon-64bit.iso
linuxmint-19.1-xfce-32bit.iso
lubuntu-18.04-alternate-amd64.iso
Now I would like that the file supported_systems had the content like this:
clonezilla*
debian*
linuxmint*
lubuntu*
So I have to match only the name of the distro without harcoding every version/release.
Using code similar to the one above ("${supported_isos[@]}" =~ "$(basename "$iso")") is this possible? If not, I'm open to suggestions.