LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   hi ,i have to grep a series say 98782 from a file containing series how can i grep it (https://www.linuxquestions.org/questions/linux-newbie-8/hi-i-have-to-grep-a-series-say-98782-from-a-file-containing-series-how-can-i-grep-it-809747/)

sushil.cool 05-24-2010 05:00 AM

hi ,i have to grep a series say 98782 from a file containing series how can i grep it
 
i have to grep a series say 98782 from a group by series in a file ,plz tell me how can i grep the series.

druuna 05-24-2010 05:12 AM

Hi,

Could you give an example of what you want? The above description is not very clear.

syg00 05-24-2010 05:13 AM

Even better - show us what you have attempted, and why you need help.

ajeetsinghraina 05-24-2010 05:19 AM

grep "98782" <filename>

sushil.cool 05-25-2010 06:20 AM

example
 
there is a file of mobile numbers having lacs of mobile number
i have to grep the count of a particular series say 9872 from that file
problem is that when i am using grep "9872" its works but it is searching the numbers like
9156239872
9198720002
As it find the series 9872 at last and middle.
I have to find only those number start with series "9872"
9872 may be at middle or end but i have to find numbers start with 9872.

druuna 05-25-2010 06:23 AM

Hi,

As ajeetsinghraina guessed correctly, you can use grep to do that.

grep "^9872" filename should do the trick.

The ^ tells grep to only look for entries that start with the search pattern.

Hope this helps.

linuxlover.chaitanya 05-25-2010 06:27 AM

grep ^9872 <filename>

Edit: druuna beat on this.


All times are GMT -5. The time now is 02:44 PM.