LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   help with grep... only print specific string with multiple matches? (https://www.linuxquestions.org/questions/linux-general-1/help-with-grep-only-print-specific-string-with-multiple-matches-725200/)

trey85stang 05-11-2009 09:20 AM

help with grep... only print specific string with multiple matches?
 
I have a text file with hard drive image checksums and file names like so:

Code:

e651cc31e6837e9718a9e216669eacd2 hda
011c0bc5930ba01a479755fa62dfabe8 hda1.first_sectors
459ebcaa3131929b356c5227aa26745f hda2.000
f63d3c1bca1db879bdd924cbc71e533c hda2.first_sectors

and I have loop that checks the md5sums against the files after copying them across the network. the problem is hda is obviously not working as it pulls up the above 4 lines. Is there anyway to grep to exclude everything except an exact match of "hda"?

ghostdog74 05-11-2009 09:25 AM

Code:

grep -wv 'hda' file

trey85stang 05-11-2009 09:29 AM

Quote:

Originally Posted by ghostdog74 (Post 3537096)
Code:

grep -wv 'hda' file

Awesome, I kind of asked backwards... grep -w does exactly what I want!

Thanks,
Trey


All times are GMT -5. The time now is 11:01 AM.