I'm trying to get a list of some deleted files in my git repo using a bash script. This however, needs to be run in a docker container and in a one liner.
I also want to only create the list of the files if there are actually any deleted files.
What I'm currently doing is:
[[ "$(git ls-files --deleted)" =~ "filename" ]] && git ls-files --deleted >! deleted_files.txt
Locally, this works fine. When I try in docker:
docker exec my-container bash -c "[[ $(git ls-files --deleted) =~ "filename" ]] && git ls-files --deleted >! deleted_files.txt"
I get this error, however:
bash: -c: line 0: conditional binary operator expected
bash: -c: line 0: syntax error near `filename'
bash: -c: line 0: `[[ =~ filename ]] && git ls-files --deleted >! deleted_files.txt'
My bash knowledge is extremely lacking, so there is a great chance I'm doing something wrong, but not exactly sure what.
Thanks in advance!