LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 05-17-2012, 08:24 AM   #1
nblarson
LQ Newbie
 
Registered: May 2012
Posts: 2

Rep: Reputation: Disabled
grep issue


So I banged my head against the wall for awhile trying to figure out this simple grep. Essentially, I have a field in a tab delimited file that can take on various forms:

A/T
TA/T
A/TGAC

I just want the lines where the field is [ACTG]/[ACTG], so

A/T - Yes
TA/T - No
A/TGAC - No

So I figured the following would be fine:

grep " [ACTG]\/[ACTG] " file.in > file.out

But I get nothing. Of course if I drop the spaces, I get everything. I've also tried:

grep \s[ACTG]\/[ACTG]\s
grep [:space:][ACTG]\/[ACTG][:space:]
grep \t[ACTG]\/[ACTG]\t

They all return nothing.

Is there something I'm forgetting?
 
Old 05-17-2012, 08:38 AM   #2
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983
Yes. Word boundaries:
Code:
grep '\<[ACTG]\/[ACTG]\>' file
or using the proper grep option:
Code:
grep -w '[ACTG]\/[ACTG]' file
And welcome to LinuxQuestions!
 
Old 05-17-2012, 09:03 AM   #3
nblarson
LQ Newbie
 
Registered: May 2012
Posts: 2

Original Poster
Rep: Reputation: Disabled
Thanks, that did it!

Feel like I'm learning a new language and I've got all the big words down and none of the basics :P
 
  


Reply



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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] ls grep issue Blizzard Linux - General 7 05-03-2012 03:38 AM
grep issue jack_9 Linux - Newbie 21 03-06-2012 06:02 AM
grep issue alape Linux - General 2 01-28-2012 11:49 AM
grep issue with SuSE 9 vm_devadas SUSE / openSUSE 6 01-24-2007 09:48 AM
grep -v issue lleemon Linux - General 7 06-16-2003 03:50 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 10:55 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