Celeb Glow
news | March 18, 2026

How to cut part of line?

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

4 Answers

Tryt to do it this way:

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

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
9
inxi -Gx | grep -oi nv.*]
inxi -Gx | awk '/Device/{print $2,$3,$4,$5}'

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.

1

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy