-1

I want to list all my drivers from the file /etc/X11/xorg.conf

my file looks like this:

section "input class"
        identifier    "blablabla"
        driver        "my driver here"

I want to list every driver in this file using regex. I thought I could use something like this : grep -i "driver" and concat it with the pipe and then, find what is between ""

but this is not working grep -i "driver" | grep -i "\"(.*?)\""

I think the problem is whitespaces but how could I use [[:space:]] to ignore them ?

Thanks for all help!

Tuxdude
  • 47,485
  • 15
  • 109
  • 110
Isael
  • 1

1 Answers1

1

Not the best solution, but something that I can quickly think of:

grep driver /etc/X11/xorg.conf  | cut -d '"'  -f 2

The grep command would list all lines containing the pattern driver. The -d argument to cut specifies the delimiter, and the -f specifies the fields you want to print

You could do the same using awk in a single command:

awk -F '"' -v PATTERN="driver" '$0 ~ PATTERN { print $2 }' /etc/X11/xorg.conf
Tuxdude
  • 47,485
  • 15
  • 109
  • 110
  • Oh I see, its working but is there any other ways to get the same reuslt without using cut ? im not familiar with the cut command assuming that im learning GNU. – Isael Mar 16 '13 at 06:40