Shell

為什麼數字在 ssh 上四捨五入?

  • July 24, 2015
localhost:~ $ df -k / | awk '{print $3/1024/1024/1024}'
0
0.00618061

localhost:~ $ ssh localhost "df -k / | awk '{print $3/1024/1024/1024}'"
01
01

當您將參數傳遞給 SSH 時,您需要更多的引用。試試這個:

ssh localhost "df -k / | awk '{print \$3/1024/1024/1024}'"
0
0.00623375

注意\之前的$3.

引用自:https://unix.stackexchange.com/questions/218085