I have a bash script that deals with files. It find
s all the files in one directory and searches for the name of each in another directory. For that it uses
"${myfiletobesearched}"
inside the script. However if the file name contains [ or ], the script won't find it in the second directory, even if a copy of the file is there as well. What can I do, so that the file names are recognized to be the same?
I was able to narrow the problem down to an example.
myfile="My File [Official Awesome File].txt"
find ./ -name "${myfile}" -type f
does give any output, even if there is a file with that name. To write \[
or something like that is of course not an option, because myfile
comes from inspecting a directory.
Here is the script: https://gist.github.com/Make42/5bdae5e4de32cff0d01c9486b09383ee