grep only macting pattern

General support questions
Post Reply
robertw
Posts: 189
Joined: 2012/04/25 13:26:59

grep only macting pattern

Post by robertw » 2018/11/08 14:57:03

hi all,

i only want to show the result if it matches the pattern ONLY and not just part of the pattern, this is very important as im going to be installing drivers using the if/then/else statments

i will show you what im trying to do

lspci | grep -iwe "980"
06:00.0 VGA compatible controller: NVIDIA Corporation GM200 [GeForce GTX 980 Ti] (rev a1)

so really it shouldnt have found it as all i put was 980 not 980 ti

thanks,

rob

lightman47
Posts: 1522
Joined: 2014/05/21 20:16:00
Location: Central New York, USA

Re: grep only macting pattern

Post by lightman47 » 2018/11/08 15:05:14

it did what you asked; you requested 980 and it found it. Perhaps you meant to ask it to find lspci | grep -iwe "980 Ti" or some thing else so that every instance of 980 wouldn't be searched for?

tunk
Posts: 1206
Joined: 2017/02/22 15:08:17

Re: grep only macting pattern

Post by tunk » 2018/11/08 15:28:55

Or:
lspci | grep 980]
lspci | grep 980 | grep -v " 980 "

User avatar
TrevorH
Site Admin
Posts: 33215
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: grep only macting pattern

Post by TrevorH » 2018/11/08 15:40:55

grep GeForce /usr/share/hwdata/pci.ids | grep "\b980\b" answers your question about how to find just " 980 " but that would still find the Ti version since it does contain the pattern you wanted.
The future appears to be RHEL or Debian. I think I'm going Debian.
Info for USB installs on http://wiki.centos.org/HowTos/InstallFromUSBkey
CentOS 5 and 6 are deadest, do not use them.
Use the FAQ Luke

robertw
Posts: 189
Joined: 2012/04/25 13:26:59

Re: grep only macting pattern

Post by robertw » 2018/11/08 21:21:01

solved

lspci | grep -owie "980]"

so the thing i was missing was the ]

i put the o in so i see the output

Post Reply