从字符串中提取数字

r1si

我有以下字符串

Device Enabled (126):   1

我可以只提取126和NOT(126)的变量VAR吗?

ps 126 =随机数

请帮我 !

编辑我粘贴我的脚本,以便您可以了解解决方案

ID=`xinput list | grep -i TouchPad | awk -F= '{ print $2}' | awk '{print $1}'`
VALOREENABLE=`xinput list-props $ID | grep -i Enabled |awk '{print $3}'`
VALORESENSE=`xinput list-props $ID | grep -i Profile |awk '{print $3}'

在我的情况下VALOREENABLE =(126)和VALORESENSE(256)我只想要126,256而没有():(`

醉酒

有很多方法可以做到这一点。这是我首先想到的一个:

VALOREENABLE=`xinput list-props $ID | grep -i Enabled | grep -o "(.*)" | tr -d '()'`
VALORESENSE=`xinput list-props $ID | grep -i Profile | grep -o "(.*)" | tr -d '()'`

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章