我会去看看我的触摸屏是否使用自己的脚本进行了校准。 但我对 shell 脚本的经验真的很少。我希望任何人都可以帮助我。
我的想法是执行xinput --list-pros <device>
并使用条目 ...(242): <no items>
检查终端输出。
如果触摸屏未校准,则可以选择此选项,否则会出现 x/y
坐标如...(242): 1 22 333 4444
.
在我的脚本中,我将执行 xinput --list-pros <device>
并检查 grep
有条目(242)
然后检查同一行是否有条目 <no items>
。但我无法读取 xinput --list
的输出.
# read the terminal output from xinput
$xinput_output= less xinput --list-pros 7
while read $xinput_output
do
# check first line from output
grep "242" $xinput_output
if [ $? != 0]
then
break;
else
# found 242 check x/y coordinates
grep "<no items>" $xinput_ouput
if [ $? != 0]
then
#no x/y coordinates, execute xinput_calibration
xinput_calibration
exit 0
fi
fi
done < $1
最佳答案
用反引号或 $() 将命令括起来:
var=`some command` # note no $ before var
# Or by $()
var=$(some command)
# then you can now use command's output
echo $var
关于linux - shell,匹配终端输出中的字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28089341/