LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   problem with grep command (https://www.linuxquestions.org/questions/linux-newbie-8/problem-with-grep-command-594447/)

thodo 10-25-2007 04:17 AM

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

acid_kewpie 10-25-2007 04:20 AM

check the grep manpage...
Code:

      -e PATTERN, --regexp=PATTERN
              Use PATTERN as the pattern; useful to protect patterns beginning
              with -.



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