grep with "." in the string

grep with "." in the string

Post by Njwer » Thu, 27 Nov 1997 04:00:00



i am using grep on a file with string search such as 25.4.

the results list the target line contaiing 25.4 and several more lines that
dont.

without the "." embedded  a number such as 34 is grepped correctly.

????

 
 
 

grep with "." in the string

Post by Charles Dem » Thu, 27 Nov 1997 04:00:00




>i am using grep on a file with string search such as 25.4.

>the results list the target line contaiing 25.4 and several more lines that
>dont.

>without the "." embedded  a number such as 34 is grepped correctly.

try:

grep -e '25\.4' infile

or

grep -e'25[.]4' infile

the "." is a special character (except when inside square brackets)
and if you want the actual character, you must precede the special
character with a "\".  RTFM  man grep .

Chuck Demas
Needham, Mass.

--
  Eat Healthy    |   _ _   | Nothing would be done at all,

  Die Anyway     |    v    | That no one could find fault with it.


 
 
 

grep with "." in the string

Post by Ian Goldstei » Thu, 27 Nov 1997 04:00:00


escape the dot grep 2\.5\.4

> i am using grep on a file with string search such as 25.4.

> the results list the target line contaiing 25.4 and several more lines that
> dont.

> without the "." embedded  a number such as 34 is grepped correctly.

> ????


--
Ian

======================================================================

Enterprise Systems Management               |
On assignment at Union Bank of Switzerland  |
======================================================================

 
 
 

grep with "." in the string

Post by Reinier Pos » Sat, 29 Nov 1997 04:00:00



>try:

>grep -e '25\.4' infile

>or

>grep -e'25[.]4' infile

or

  fgrep 25.4 infile

Also

  man grep
  man fgrep
  man egrep

can be useful.

--
Reinier

 
 
 

grep with "." in the string

Post by Eric Kleinber » Mon, 01 Dec 1997 04:00:00


The "." matches any single character. If you want to grep for a period
explicitly, use "grep \.". Study regular expressions if you don't understand
this...


>i am using grep on a file with string search such as 25.4.

>the results list the target line contaiing 25.4 and several more lines that
>dont.

>without the "." embedded  a number such as 34 is grepped correctly.

>????


 
 
 

grep with "." in the string

Post by Njwer » Tue, 02 Dec 1997 04:00:00


the expression is a varaiable  $input
that needs to be parsed.

The answer as was pointed out is
    fgrep or grep -f


 
 
 

1. find /from -exec grep "string" {} ";"

Subject: find /from -exec grep "string" {} ";"      How do you ...

How do I get this trick to display the filename and  line in the file
that contains the match (and line number aswell if possible)?

Normally if you say:

                 grep "string" *.c

without any options to grep you will get output that shows both the
filename and the matching line. When you use grep with the 'find -exec'
trick you only get matching lines output, without the filenames -
completely useless!

I have found that if you add the -l option to grep you will atleast get
output that shows the pathnames of files containing matches, but it won't
print the matching lines aswell, as in the normal use of grep.

2. HELP - NFS install using GE2000II Ethernet Adapter

3. mcs -a "string" vs. CC -mr,"string"

4. Clock problem with KDE 2.2

5. GETSERVBYNAME()????????????????????"""""""""""""

6. How to limit chmod function

7. """"""""My SoundBlast 16 pnp isn't up yet""""""""""""

8. Linux and Adaptec RAIDport

9. Can grep be made using "and" instead of "or"

10. A tough one with "find" and "grep"

11. "grep" gets unnecessary strings too[help]

12. Why does shutdown call "brc" without string "brc" in binary ?

13. startx returns errors "Not a declared device" or "Chipset string expected"