use grep or other command to get exactly pattern

Brian Chadwick brianchad at westnet.com.au
Sat Jan 19 02:06:35 UTC 2008


Konstantin Svist wrote:
> ann kok wrote:
>> how can use grep or use other command to get exactly
>> pattern eg: 10.0.0.7 only?
>>
>> eg: grep 10.0.0.7 file. I want to get 10.0.0.7 only
>> not 
>> 10.0.0.71
>> 10.0.0.72
>> 10.0.0.7
>>   
>
>
> Use egrep instead - it allows you to use regular expressions.
> Then write a regexp for your case. For instance, if you have 
> end-of-line right after the IP address, you can use '10\.0\.0\.7$'
>
>
>
grep "10.0.0.7" file

the inverted commas are required




More information about the fedora-list mailing list