1

I have the following logs:

S1 # ls /var/log/*/server
/var/log/P3/server:
apps  logs

/var/log/P4/server:
apps  logs

/var/log/S1/server:
apps  logs

--I would like to cycle through them via ssh specifically (for prototyping something more elaborate) but I can't, it will repeat one of the files three times rather then going through all 3:

SC-1# ssh SC-1 "for i in /var/log/*/server; do echo $i; done"
/var/log/SC-1/server
/var/log/SC-1/server
/var/log/SC-1/server

Also it is not possible for me to put this in a script and then ssh to run the script

4

1 回答 1

1

使用单引号防止$i被外壳插入。

ssh SC-1 'for i in /var/log/*/server; do echo $i; done'
于 2013-04-30T20:07:46.963 回答