ssh user@server "sudo tar -czf - -C /path/To/Directory *.properties" | tar xzf -
It fails with following error -
tar: *.properties: Cannot stat: No such file or directory
tar: Exiting with failure status due to previous errors
If I ssh to server and then on server, instead of tar -czf -
use tar -czf abc.tgz
and remove the piped command at the end, it works correctly i.e. compress all the .properties file from the directory?
I have tried using --wildcards parameter as well as -P and the complete path ending with *.properties, but they didn't work either.
The shell at the far end expands *.properties in
user
's home directory, before it execstar
. I'm guessing there's no matching files in~user
.What you probably want is something more like (assuming
user
can access the directory)Or, use
tar
's--wildcards
option, and stop the remote shell expanding the argument: