0

I'm trying get conky working on my system, and I'm stuck on how to format a specific shell variable to display my VGA. From shell I get my VGA using:

lspci | grep VGA

The output:

01:00.0 VGA compatible controller: NVIDIA Corporation G71M [GeForce Go 7900 GS] (rev a1)

For my goal I need have this output formatted for something like: (The contents inside of [])

GeForce Go 7900 GS

The idea is this should be dynamic for every user (I`m not willing to hard-code it).

The second output is about the current driver. I`m getting the info from this output:

glxinfo | more | grep "renderer string"

This last one works pretty nice with:

${voffset 2}${font StyleBats:size=10}${color2}d${voffset -2}${font DroidSans:size=8.6}${color3}${offset 5}nVidia GeForce 7600 GT${alignr}${font DroidSans:size=8.3}${pre_exec glxinfo | more | grep 'renderer string' | awk -F':' '{print $2}'}${font}

The output:

Gallium 0.4 on NV49

If I find how to format the first variable, the final output will be:

GeForce Go 7900 GS Gallium 0.4 on NV49

Thanks in advice!!!

4
  • 1
    lspci | awk -F'[][]' '/VGA/{print $2}'...
    – jasonwryan
    Commented Jul 18, 2015 at 20:46
  • Worked!!! Thank you very much. I have tested this one and worked too: lspci | grep VGA | awk -F'[' '{print $2}' | awk -F']' '{print $1}' But, yours command seems very better!!!
    – Wisdom
    Commented Jul 18, 2015 at 21:00
  • Yes, Awk has pattern matching so the grep is redundant...
    – jasonwryan
    Commented Jul 18, 2015 at 21:10
  • How can I set your answer as correct? There no option for it
    – Wisdom
    Commented Aug 10, 2015 at 4:48

1 Answer 1

0
lspci | awk -F'[][]' '/VGA/{print $2}'

Where the field separator is set as [ and ] and the pattern is VGA, print the second field (ie., the match between [..].

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .