LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 05-11-2009, 09:20 AM   #1
trey85stang
Senior Member
 
Registered: Sep 2003
Posts: 1,091

Rep: Reputation: 41
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"?
 
Old 05-11-2009, 09:25 AM   #2
ghostdog74
Senior Member
 
Registered: Aug 2006
Posts: 2,697
Blog Entries: 5

Rep: Reputation: 244Reputation: 244Reputation: 244
Code:
grep -wv 'hda' file
 
Old 05-11-2009, 09:29 AM   #3
trey85stang
Senior Member
 
Registered: Sep 2003
Posts: 1,091

Original Poster
Rep: Reputation: 41
Quote:
Originally Posted by ghostdog74 View Post
Code:
grep -wv 'hda' file
Awesome, I kind of asked backwards... grep -w does exactly what I want!

Thanks,
Trey
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
bash replace all matches of regex substring in string nickleus Linux - General 3 04-30-2011 11:08 AM
Capturing only matches in grep/egrep via shell/bash koobi Programming 4 03-28-2009 12:37 PM
limiting line matches in grep genderbender Programming 5 07-05-2008 05:18 PM
grep regex . matches new lines?! lambchops468 Linux - Newbie 3 03-24-2008 09:19 PM
Regex Question: Only print part of line that matches TheMeteorPolice Programming 5 01-12-2006 01:21 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 06:37 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration