rm to exclude file
I am using !(filename) sytax to exclude file from rm command.
It's working when I run it directly in bash. But not working when used in a ssh command like below: ssh 10.23.10.138 'rm -rf /tmp/td/d1/d2/!(*.py)' bash: -c: line 0: syntax error near unexpected token `(' bash: -c: line 0: `rm -rf /tmp/td/d1/d2/!(*.py)' Can someone tell me why ? Thank you in advance! |
run: shopt -s extglob
then try running the command again it should be okay. to turn off: shopt -u extglob |
Login first and run bash as local.
|
Quote:
|
Quote:
|
Quote:
|
I think the sshd is getting confused between a command and a shell...
You might try Code:
ssh 10.23.10.138 bash -c 'rm -rf /tmp/td/d1/d2/!(*.py)' |
Quote:
|
as Jpollard suggested try double quotes:
Quote:
|
You might also include "-v" in the bash options so that you can see what command line actually got passed.
|
You probably need to use single-quotes to enclose the command, which then itself includes quotes to tell the shell on the other side not to do its own expansion.
But I admit that I'm getting a little froggy about this. I'd use ssh to execute some sort of script on the remote side which does your bidding. |
All times are GMT -5. The time now is 09:27 PM. |