我正在尝试使用 grep 在命令行上解析出字符串属性。我正在使用以下方式获取属性:
jarrett@jarrett-g74s:~$ xinput --list-props "FSPPS/2 Sentelic FingerSensingPad"
Device 'FSPPS/2 Sentelic FingerSensingPad':
Device Enabled (131): 0
Coordinate Transformation Matrix (133): 1.000000, 0.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 0.000000, 1.000000
Device Accel Profile (257): 0
Device Accel Constant Deceleration (258): 1.000000
Device Accel Adaptive Deceleration (259): 1.000000
Device Accel Velocity Scaling (260): 10.000000
Device Product ID (248): 2, 15
Device Node (249): "/dev/input/event9"
Evdev Axis Inversion (261): 0, 0
Evdev Axes Swap (263): 0
Axis Labels (264): "Rel X" (141), "Rel Y" (142)
Button Labels (265): "Button Left" (134), "Button Middle" (135), "Button Right" (136), "Button Wheel Up" (137), "Button Wheel Down" (138), "Button Horiz Wheel Left" (139), "Button Horiz Wheel Right" (140), "Button Unknown" (251), "Button Unknown" (251), "Button Forward" (254), "Button Back" (255), "Button Unknown" (251), "Button Unknown" (251), "Button Unknown" (251), "Button Unknown" (251)
Evdev Middle Button Emulation (266): 0
Evdev Middle Button Timeout (267): 50
Evdev Third Button Emulation (268): 0
Evdev Third Button Emulation Timeout (269): 1000
Evdev Third Button Emulation Button (270): 3
Evdev Third Button Emulation Threshold (271): 20
Evdev Wheel Emulation (272): 0
Evdev Wheel Emulation Axes (273): 0, 0, 4, 5
Evdev Wheel Emulation Inertia (274): 10
Evdev Wheel Emulation Timeout (275): 200
Evdev Wheel Emulation Button (276): 4
Evdev Drag Lock Buttons (277): 0
该物业是Device Enabled
。所以,我像这样使用grep:
jarrett@jarrett-g74s:~$ xinput --list-props "FSPPS/2 Sentelic FingerSensingPad" | grep "Device Enabled (131):"
Device Enabled (131): 0
哪个有效。但是,我想对整个属性字符串(包括末尾的 0 或 1)进行 grep,所以我试试这个:
jarrett@jarrett-g74s:~$ xinput --list-props "FSPPS/2 Sentelic FingerSensingPad" | grep "Device Enabled (131):*0"
但是,这不会返回任何内容。我放了一个*0
,我认为它会覆盖 0 之前的任何字符。有人知道为什么这不起作用吗?(我是 bash 工作的新手,我实际上是在 bash 脚本中运行它,但我也在命令行中运行它以进行测试,但它仍然不起作用)。
我很感激任何帮助!
干杯