Wednesday, May 1, 2024
 Popular · Latest · Hot · Upcoming
2
rated 0 times [  2] [ 0]  / answers: 1 / hits: 15236  / 2 Years ago, wed, march 2, 2022, 7:33:25

i have the following string



Device Enabled (126):   1


can i extract in a variable VAR only 126 and NOT (126) ?



p.s 126 = random number



please help me !



EDIT
i paste my script so u can understand the solution



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}'


in my case VALOREENABLE = (126)
and VALORESENSE (256) i want 126, 256 only without () :(`


More From » bash

 Answers
6

There are lots of ways to do it. Here's the one that first comes to mind for me:



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

[#41063] Friday, March 4, 2022, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
uffno

Total Points: 283
Total Questions: 93
Total Answers: 111

Location: Saint Vincent and the Grenadines
Member since Thu, Oct 15, 2020
4 Years ago
uffno questions
Thu, Sep 2, 21, 18:08, 3 Years ago
Sun, Apr 2, 23, 15:15, 1 Year ago
Sat, Jan 8, 22, 16:37, 2 Years ago
;