The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Operating Systems > Linux
.
google unix.com



Linux RedHat, Ubuntu, SUSE, Fedora, Debian, Mandriva, Slackware, Gentoo linux, PCLinuxOS. All Linux questions here!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
grep with regular expression optional value necroman08 Shell Programming and Scripting 11 10-05-2009 09:03 AM
grep regular expression Calypso Shell Programming and Scripting 7 05-18-2009 07:08 AM
grep with regular expression daikeyang Shell Programming and Scripting 6 03-22-2009 08:46 PM
regarding grep regular expression ukatru UNIX for Advanced & Expert Users 2 10-22-2008 11:47 PM
grep : regular expression RishiPahuja Shell Programming and Scripting 10 09-13-2005 12:53 AM

Reply
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 09-23-2009
sogi sogi is offline
Registered User
  
 

Join Date: May 2009
Posts: 13
how to grep special character regular expression?

Hi

I have 2 files

file1:

Code:
SNP_A-2208459   
SNP_A-4215188   
SNP_A-2012248   
SNP_A-1882998

file2:

Code:
CHR  SNP  UNADJ       BONF         HOLM     *   *    *  etc.
  19   SNP_A-2236481  1.742e-26  5.442e-21    
  13   SNP_A-4204405  8.643e-07  1.505e-06   
   3    SNP_A-1860908  4.483e-06  7.279e-06
   7    SNP_A-1990194  7.434e-06  1.181e-05
   *
   *
   *
   etc. (thousands of rows)
Note: file2 also contains the entries listed in file1

Question: I'm using grep -w -f file1 file2 > file3 to match in file2 only the entries listed in file1, BUT this does not work ; the output file3 is giving me everything listed in file2 .

Can anyone help? pleaaaaaaaaaaaaase

Thank you!

Last edited by vgersh99; 09-23-2009 at 05:49 PM.. Reason: code tags, PLEASE!
  #2 (permalink)  
Old 09-23-2009
Corona688 Corona688 is offline
Registered User
  
 

Join Date: Aug 2005
Location: Saskatchewan
Posts: 1,929
What does -F do if used instead of -f?
  #3 (permalink)  
Old 09-23-2009
vgersh99's Avatar
vgersh99 vgersh99 is online now Forum Staff  
Moderator
  
 

Join Date: Feb 2005
Location: Boston, MA
Posts: 5,119
To keep the forums high quality for all users, please take the time to format your posts correctly.

First of all, use Code Tags when you post any code or data samples so others can easily read your code. You can easily do this by highlighting your code and then clicking on the # in the editing menu. (You can also type code tags [code] and [/code] by hand.)

Second, avoid adding color or different fonts and font size to your posts. Selective use of color to highlight a single word or phrase can be useful at times, but using color, in general, makes the forums harder to read, especially bright colors like red.

Third, be careful when you cut-and-paste, edit any odd characters and make sure all links are working property.

Thank You.

The UNIX and Linux Forums
  #4 (permalink)  
Old 09-23-2009
sogi sogi is offline
Registered User
  
 

Join Date: May 2009
Posts: 13
-F does not work only either.
  #5 (permalink)  
Old 09-23-2009
thegeek thegeek is offline
Registered User
  
 

Join Date: Apr 2009
Location: /usr/bin/vim
Posts: 438
1. -w means word. And -(hyphen) is not a word character.

So file3 will not have any content, ( by the sample input you gave ). Confirm whether you are right in saying that.

2. Solution.
Code:
grep -f file1 file2
Let us know whether this helped.
  #6 (permalink)  
Old 09-25-2009
sogi sogi is offline
Registered User
  
 

Join Date: May 2009
Posts: 13
thegeek;

Thank you for trying to help me, but grep -f file1 file2 > file3
DOES NOT WORK.


---------- Post updated 09-25-09 at 03:56 PM ---------- Previous update was 09-24-09 at 09:47 PM ----------

I also deleted the hyphens, underscores and letters from the in both files but the grep -f file1 file2 > file3 does not work
SNP_A-2208459

---------- Post updated at 03:58 PM ---------- Previous update was at 03:56 PM ----------

Ok, I give up with this forum, I guess nobody wants to help.
  #7 (permalink)  
Old 09-25-2009
treedroppings treedroppings is offline
Registered User
  
 

Join Date: Sep 2009
Posts: 2
did you try the man pages?

i think diff may be another way around it check man diff also
Reply

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 07:02 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0