Hi
This time I'm trying to grep for an exact match
e.g
cat.dog.horse.cow.bird.pig
horse.dog.pig
pig.cat.horse.dog
horse
dog
dog
pig.dog
pig.dog.bird
how do I grep for dog only so that a wc -l would result 2 in above case.
Thanks in advance
---------- Post updated at 06:33 AM ---------- Previous update was at 06:29 AM ----------
I have tried
grep '^dog$' <filename>
but doesnt work!
grep '^dog$' <filename>
does work on Solaris.
What OS are you on?
Try using 'egrep' instead.
Post the output of cat -vet filename
using the code tags.
Do you have any leading/trailing spaces/tabs?
......
---------- Post updated at 06:49 AM ---------- Previous update was at 06:48 AM ----------
SunOS alps 5.10 Generic_125100-05 sun4v sparc SUNW,Sun-Fire-T200
---------- Post updated at 06:49 AM ---------- Previous update was at 06:49 AM ----------
alps$ cat -vet 2503test
cat.dog.horse.cow.bird.pig$
horse.dog.pig$
pig.cat.horse.dog$
horse$
dog$
dog$
pig.dog$
pig.dog.bird$
---------- Post updated at 06:54 AM ---------- Previous update was at 06:49 AM ----------
I see this works hoever that was juat an example
The actual file I am trying to edit is as below. I have had to remove the actual numbers and replace with xxxx for showing here. What I am trying to do is grep for the word internet only
24 |1111111|internet
2 |1111111|open.internet
1 |1111111|internet
4 |2222222|open.internet
2 |2222222|open.internet
1 |1111111|open.internet
4 |1234567|internetctrlbar
1 |7654321|internet
84 |1234567|internet.itelcel.com
For grep-ing try this:
grep '|internet$' myFile
For anything else, please post the desired output given your sample input.
1 Like
Perfect. Many Thanks vgersh99 for your time in this. It is much appreciated.
rob171171