LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
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 10-25-2007, 05:17 AM   #1
thodo
LQ Newbie
 
Registered: Apr 2006
Posts: 4

Rep: Reputation: 0
problem with grep command


Hi guys,

I have the following problem when using the grep command:

I want to select some entries from a file (source_file.cat),
using as a reference a one-column file (ref_file.cat)
with entries (I call them "ID") common in both files, such as

75963
71903
-20486

the grep command will work fine for the first two entries, but it will complain
for the third one as grep does not like the "-" sign. It will only work if I convert
the - sign to '\-' in my do loop. Is there a smart way of doing that?

Thanks in advance,

Thodo
 
Old 10-25-2007, 05:20 AM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
check the grep manpage...
Code:
       -e PATTERN, --regexp=PATTERN
              Use PATTERN as the pattern; useful to protect patterns beginning
              with -.
 
  


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



Similar Threads
Thread Thread Starter Forum Replies Last Post
grep command karimasif Linux - Newbie 2 09-05-2007 12:54 PM
grep command sgarci Linux - General 3 08-28-2006 08:13 AM
how to use grep command sharonyiisl Linux - Newbie 7 05-28-2006 04:46 PM
grep command in c????? alnreddy Linux - Software 1 12-30-2004 02:01 AM
Simple grep command problem acis Linux - General 2 07-16-2004 01:21 PM

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

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