Reputation: 3
how can I set up an alias for this command? (because it has multiple quotations)
rsync -azv -e 'ssh -o "ProxyCommand ssh -A some@place -W %h:%p"' user@xxx:/data/as ~/
Upvotes: 0
Views: 947
Reputation: 241838
Just use single quotes and replace each single quote with '\''
.
alias XYZ='rsync -azv -e '\''ssh -o "ProxyCommand ssh -A some@place -W %h:%p"'\'' user@xxx:/data/as ~/'
Or, use a function instead of an alias
XYZ () {
rsync -azv -e 'ssh -o "ProxyCommand ssh -A some@place -W %h:%p"' user@xxx:/data/as ~/ "$@"
}
It's more flexible and gives you a chance to parameterize the command later.
Upvotes: 3
Reputation: 21
Escape the inner double quote and quote everything with double quote because you cannot escape single quote but only double quote. (sounds a bit funny)
alias foobar="rsync -azv -e 'ssh -o \"ProxyCommand ssh -A some@place -W %h:%p\"' user@xxx:/data/as ~/"
You might want to check this answer.
Upvotes: 0