bash 新手在这里。
我想使用以下简单脚本作为启用/禁用笔记本电脑触摸板的快捷方式:
#!/bin/bash
result=$(xinput --list-props 11 | grep "Device Enabled")
echo $result
# Output: Device Enabled (140): 1
if [[ "$result" = "Device Enabled (140): 1" ]]; then
`xinput set-prop 11 "Device Enabled" 0`
else
`xinput set-prop 11 "Device Enabled" 1`
fi
但是,从未输入 if 条件。echo $result
表明该变量确实包含我要比较的字符串值。我已经搜索了一段时间,但根本无法弄清楚为什么结果变量和字符串在 if 条件中不匹配。