linux - Not getting right output if i execute command via ssh -
the output of following command
sudo find / -xdev -type f -size +100000 -name "*.log" -exec gzip -v {} \; 2>&1 | awk '{print $6}'
give me
/opt/testing3/cat1.log.gz /opt/testing3/cat2.log.gz /opt/testing3/cat3.log.gz /opt/testing3/cat4.log.gz /opt/testing3/cat5.log.gz /opt/testing3/cat6.log.gz /opt/testing3/cat7.log.gz
however if via ssh gives me:
ssh user@hostname "sudo find / -xdev -type f -size +100000 -name \"*.log\" -exec gzip -v {} \; 2>&1 | awk '{print $6}'"
results in
/opt/testing3/cat1.log: 95.4% -- replaced /opt/testing3/cat1.log.gz /opt/testing3/cat2.log: 95.4% -- replaced /opt/testing3/cat2.log.gz /opt/testing3/cat3.log: 95.4% -- replaced /opt/testing3/cat3.log.gz /opt/testing3/cat4.log: 95.4% -- replaced /opt/testing3/cat4.log.gz /opt/testing3/cat5.log: 95.4% -- replaced /opt/testing3/cat5.log.gz /opt/testing3/cat6.log: 95.4% -- replaced /opt/testing3/cat6.log.gz /opt/testing3/cat7.log: 95.4% -- replaced /opt/testing3/cat7.log.gz
why output different? seems awk not executed.
you have escape "$" symbol, in order not locally, pass remotely.
$ ssh $hostname "ls -l /tmp | tail -1 | awk '{print $6}'" -rw-r--r-- 1 root root 0 apr 29 01:31 file.log $ ssh $hostname "ls -l /tmp | tail -1 | awk '{print \$6}'" apr
Comments
Post a Comment