-1

I need to cut line in specific moment, I want to display GPU name, but only name, nothing else.

inxi -Gx | grep Device showing:

Device-2: NVIDIA GK107GLM [Quadro K1100M] vendor: Dell driver: nouveau

I want it to show something like this

NVIDIA GK107GLM [Quadro K1100M]

How to cut this to show only name? Is there a way to print range, in this case from word Device to word vendor.

4 Answers4

3

Tryt to do it this way:

inxi -Gx | sed -n 's/.*Device-.*: \(.*\) vendor.*/\1/p'
0

Something like:

D=$(inxi -Gx | grep Device)

if [[ $D =~ ^Device-2:([[:print:]])vendor:([[:print:]])driver:([[:print:]]*)$ ]] then echo "Found Device: ${BASH_REMATCH[1]}" else echo "Did not find device" fi

0
inxi -Gx | grep -oi nv.*]
inxi -Gx | awk '/Device/{print $2,$3,$4,$5}'
HatLess
  • 115
0

inxi -Gx | grep Device | cut -d ':' -f 2 | sed 's/ vendor//'

This cuts the output into fields using ":" as a delimiter, then it gives you the second field. Use sed then to strip the specific word off the end.

If you know the length then you can cut a range using cut, see man cut for details.

pbhj
  • 3,364