I hope I can explain this correctly. I am using Bash-4.2 for my shell.
I have a group of file names held in an array. I want to compare the names in this array against the names of files currently present in a directory. If the file does not exist in the directory, that is not a problem. However, if any file exists in the directory that is not also listed in the array, the file in the directory should be deleted. I just cannot find a relatively simple way to do this.
I have tried literally dozens of ways to do it, and while I have certainly found a few that work, they are all to inflated in my opinion. I am just trying to find an eloquent method if possible.
Bash 4x supports associative arrays I believe; however, I have no experience with them. I just use the regular arrays. If you could give me an example of how this would work with an associative array, I might learn something.