I'm trying to make a script for deploying my application but I am running into a problem. One of the command includes deleting all files except my .env
Using rm -rv !(.env)
works great when connected manually with ssh but for some reason, doing ssh -i sshKey ubuntu@ipAdress 'rm -rv !(.env)'
in powershell gives me the following error :
bash: -c: line 0: syntax error near unexpected token `('
bash: -c: line 0: `rm -rv !(.env)'
I have tried escaping the parenthesis with a backslash like ssh -i sshKey ubuntu@ipAdress 'rm -rv !(.env)'
but then the error becomes :
rm: cannot remove '!(.env)': No such file or directory
Does anyone have any idea how this is happening ?