GREP??

That’s some content of a file:

01:00.0 VGA compatible controller [0300]: nVidia Corporation GeForce 8800 GT [10de:0611] (rev a2)

and i want a script to find matching pattern from this exact part of text :] in one of 4 files, one of the files has that string 0611 and i need it to print the file name where it has been found. How can i accomplish that??

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Well there are a lot of possibilities here… what have you tried so
far? If you really want whatever is in either of those parts of the
string (delimited by the colon) or you want the entire string (including
the colon) then that shouldn’t be too bad, though you may need a couple
lines of code in a script instead of just a one-liner depending on the
complexity. On this you are not clear, though… you mention wanting
to match an exact part of text including brackets and text with a colon
in the middle, but then you mention a file only having 0611 in it.

If you can provide a couple sample files (those four you mentioned) and
what you have tried so far I’ll bet this can be resolved quickly.
‘grep’ is not likely to be the only command though… I’ll bet ‘awk’
will also come in handy.

Good luck.

BenderBendingRodriguez wrote:
> That’s some content of a file:
>
> 01:00.0 VGA compatible controller [0300]: nVidia Corporation GeForce
> 8800 GT [10de:0611] (rev a2)
>
> and i want a script to find matching pattern from this exact part of
> text :] in one of 4 files, one of the files has that string
> 0611 and i need it to print the file name where it has been found. How
> can i accomplish that??
>
>
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFJSGn53s42bA80+9kRAupZAJ9Z1+Tul9WCZgBp9XQCHou43TpAdACeOuyY
PnM/OfAGn3nR58eGw+GZ4fQ=
=AQRX
-----END PGP SIGNATURE-----

Maybe it will be easier to solve it, i want to extract Graphic Card’s PCI ID and then find a matching ID in one of four files containing different strings (Nvidia PCI ID’s like this:

GeForce 6800 Ultra 0x0040
GeForce 6800 0x0041
GeForce 6800 LE 0x0042
GeForce 6800 XE 0x0043

So i have 4 different files with such strings, i want to find a matching ID with the one that’s been found on my PC.Then print the output (just the name of the file where it has been found)

I want to make a script that will automate installation of drivers and also download the right ones that’s why i need some way to identify card’s and match them to the driver.

I was thinking to use sax2 to this task but i’m not quite sure it it would work and how:)

Hmm i have another idea, simpler i think. At sys/bus/pci/devices there are files describing PCI ID’s. Is there any way to use those 4 “database” files containing PCI ID’s i was talking about earlier to find matching device file at this place and then show which database contains that string? And preferably write output to a file.

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Dirty hack:

grep grep -e '\.*:.*\]' fileWithSourceData.txt | sed -r 's/.*\(....):(....)\].*/\1\\\\|\2/' filesToCheck.txt | awk -F: ‘{print
$1}’

Put all of that on one line.

In case it helps here is a base64-encoded version:

Z3JlcCBgZ3JlcCAtZSAnXFsuKjouKlxdJyBmaWxlV2l0aFNvdXJjZURhdGEudHh0ICB8IHNlZCAtciAncy8uKlxbKC4uLi4pOiguLi4uKVxdLiovXDFcXFxcfFwyLydgIGZpbGVzVG9DaGVjay50eHQgfCBhd2sgLUY6ICd7cHJpbnQgJDF9Jw==

Anyway note the two files in there you should swap out… the first is
the one with the original pattern including what you want to find and
the second is a file or a set of files that you want to search.

Good luck.

BenderBendingRodriguez wrote:
> Maybe it will be easier to solve it, i want to extract Graphic Card’s
> PCI ID and then find a matching ID in one of four files containing
> different strings (Nvidia PCI ID’s like this:
>
> GeForce 6800 Ultra 0x0040
> GeForce 6800 0x0041
> GeForce 6800 LE 0x0042
> GeForce 6800 XE 0x0043
>
> So i have 4 different files with such strings, i want to find a
> matching ID with the one that’s been found on my PC.Then print the
> output (just the name of the file where it has been found)
>
>
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFJSHLz3s42bA80+9kRAsyDAJwNG02eh1IWl1lnd7vftKswxTcbAACeLe11
tnrTZA7U1aF2D5Vj1xYTsK0=
=NSGY
-----END PGP SIGNATURE-----

It’s my first attempt to make a good script (rest was rubbish :D)
What about my last idea? Is it easir to accomplish?

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Already replied with an option.

Good luck.

BenderBendingRodriguez wrote:
> It’s my first attempt to make a good script (rest was rubbish :D)
> What about my last idea? Is it easir to accomplish?
>
>
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFJSH4U3s42bA80+9kRAkT5AJ4hdP0Sr3wrJ9vzFmYmSa8sckDfdgCdEiTd
tMZxMT9eGZ+fRL7XKWgL5zM=
=4DJO
-----END PGP SIGNATURE-----

I realize that and i’m VERY VERY thankful for that but i’m so green that it doesn’t work for me. Is there some way to use sax2 to output PCI ID of the graphic card or some conf. files he leaves somewhere with the PCI ID?

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Of that I am not sure… sorry. I don’t use SaX2 much, and when I do
it’s just to setup X directly.

Good luck.

BenderBendingRodriguez wrote:
> I realize that and i’m VERY VERY thankful for that but i’m so green that
> it doesn’t work for me. Is there some way to use sax2 to output PCI ID
> of the graphic card or some conf. files he leaves somewhere with the PCI
> ID?
>
>
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFJSIXO3s42bA80+9kRAq/JAJ4sFLeEiQM/ds0Qb0lMZ4zZshigqgCbB0jv
ByE8RM2T8NebX3TkAtNRSjs=
=GlYi
-----END PGP SIGNATURE-----

Would it be easier to search for that string from this ??
Chip: 0 is -> NVidia GeForce 8800 GT 01:00:0 0x10de 0x0611 AGP nv

It’s output from sax2 -p (or --pci)

Make it dirty and just search for a string like ‘0x0***’ from this string as there are only such ID’s with Nvidia.
There could be even 4 functions like that every searching in other file.

I’m sorry for my last post. It sounded like i wanted You to make that for me, just one small question to my last post please, how can i “extract” that variable?

Hi
Not sure what your trying to achieve but here is what I have suggested
to users (command #3) in the past for PCI ID information, just
expanded it a bit more;


/sbin/lspci -v |grep VGA
01:00.0 VGA compatible controller: nVidia Corporation NV43 [Geforce Go
6600TE/6200TE] (rev a2) (prog-if 00 [VGA controller])

/sbin/lspci -nv |grep VGA
01:00.0 0300: 10de:0146 (rev a2) (prog-if 00 [VGA controller])

/sbin/lspci -nv |grep VGA |cut -f3-4 -d ":"
10de:0146 (rev a2) (prog-if 00 [VGA controller])

/sbin/lspci -nv |grep VGA  |cut -f3-4 -d ":" |cut -f1 -d "("
10de:0146


Cheers Malcolm °¿° (Linux Counter #276890)
openSUSE 11.1 x86 Kernel 2.6.27.7-4-default
up 1 day 7:47, 2 users, load average: 0.10, 0.16, 0.17
GPU GeForce 6600 TE/6200 TE - Driver Version: 177.82

Hmm what i wanted are the last four string marked red:

01:00.0 VGA compatible controller [0300]: nVidia Corporation GeForce 8800 GT [10de:0611] (rev a2)

then grep it to database, it will show exact model of the graphic card which will show up on the screen for the user to confirm that it’s his card :slight_smile: But right now i’ll be making a very long code like

if @{graphic_card} = “Nvidia GeForce 8800GT 0x0611” ];or
@{graphic_card} = “Nvidia GeForce 8600GT 0x0511” ];then
wget http://somewhere.something
fi

The use of “or” strings, is that ok?

Seems like i can’t make up my mind,
I have one best idea otherwise i’ll ditch it:)
Lets say i have output like this below and i wan’t to ONLY search for a string 0x0611, how can i make it? (make grep ignore everything else that hasn’t got “0x0” on the beginning but how to do it??

Chip: 0 is -> NVidia GeForce 8800 GT 01:00:0 0x10de 0x0611 AGP nv

Hi
OK, so the way I understand it, your trying to compare the installed
card against the list of supported cards. Then list the releases
available for that card, then download?

I would look at processing the supported cards list into one file
first with three columns;

Card Name : PCI ID : Release

Cheers Malcolm °¿° (Linux Counter #276890)
openSUSE 11.1 x86 Kernel 2.6.27.7-4-default
up 1 day 8:31, 3 users, load average: 0.13, 0.21, 0.26
GPU GeForce 6600 TE/6200 TE - Driver Version: 177.82

Thanks!!
Now let’s start working, thank You for all Your help and patience and excuse me for being such a greenhorn…

Best Regards

NOVELL RULES!!