Reputation: 117
I'm trying to execute this command on a remote computer using ssh.
ssh user@host "if [ $(ls -la /folder | wc -l) -eq 83 ]; then true; else false; fi;"
How can I make this part $(ls -la /folder | wc -l)
to be executed on the remote computer instead of locally?
Upvotes: 0
Views: 166
Reputation: 212198
To prevent $()
from being expanded locally, put it in single quotes:
ssh user@host 'if [ $(ls -la /path | wc -l) -eq 83 ]; then true; else false; fi;'
But you don't need the if/else, just do:
ssh user@host '[ $(ls -la /path | wc -l) -eq 83 ]'
Upvotes: 1