2012-04-21 43 views
1

我試圖用grep解析出命令行中的一個字符串屬性。我用得到的屬性:使用grep for xinput屬性的問題

[email protected]:~$ 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像這樣:

[email protected]:~$ xinput --list-props "FSPPS/2 Sentelic FingerSensingPad" | grep "Device Enabled (131):" 
    Device Enabled (131): 0 

哪個有效。不過,我希望到grep對整個屬性字符串(包括無論是在年底的0或1),所以我試試這個:

[email protected]:~$ xinput --list-props "FSPPS/2 Sentelic FingerSensingPad" | grep "Device Enabled (131):*0" 

但是,不返回任何內容。我把一個*0,我原以爲會涵蓋任何字符之前的0.任何人都知道爲什麼這不起作用? (我是bash工作的新手,我實際上是在bash腳本中運行它,但我已經在命令行中運行它以進行測試,但它仍然無法運行)。

我很感激任何幫助!

乾杯

回答

2

這將是一個shell水珠正確的,而不是一個正則表達式; .*可以匹配任意數量的任意字符,但您可能更喜歡" *"(不包含引號,因爲空間不會顯示,因此不會顯示任何空格)。你有什麼,:*0,將在0之前立即匹配零個或多個冒號。

+0

謝謝@geekosaur,使用'。*'就像一個魅力!奇怪的是,「*」沒有工作(沒有引號).. – Jarrett 2012-04-21 21:00:37

+0

這可能意味着它實際上是一個選項卡,而不是空格;很難說,我現在無法可靠地檢查'xinput'行爲。 – geekosaur 2012-04-21 21:03:17

+0

啊沒有想到,可以。再次感謝。 – Jarrett 2012-04-30 17:28:48