2
我試圖列出正在使用ansible使用超過50%的安裝點安裝點使用。我在AWK上遇到錯誤。檢查使用ansible
如果我運行此命令單獨它的工作原理
df -P | awk '$5 >=90 {print}'
Filesystem 1024-blocks Used Available Capacity Mounted on
tmpfs 2097152 1948868 148284 93% /tmp
或
df -P | grep /tmp | awk '$5 >=90 {print}'
tmpfs 2097152 1948832 148320 93% /tmp
如果我把同樣的命令ansible殼失敗
這裏:
ansible all -i <hostname>, -m shell -a "df -P | grep /tmp | awk '$5 >=90 {print}'"
SSH password:
SUDO password[defaults to SSH password]:
<hostname> | FAILED | rc=1 >>
awk: >=90 {print}
awk:^syntax error
grep: write error: Broken pipe
有沒有如何做到這一點?有一個更好的方法嗎?可能會使用這些因素?
'$ 5'由當前的shell(更換從你在何處運行不可能),逃脫它。 –