LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 05-24-2010, 06:00 AM   #1
sushil.cool
LQ Newbie
 
Registered: Mar 2010
Posts: 15

Rep: Reputation: 0
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.
 
Old 05-24-2010, 06:12 AM   #2
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387
Hi,

Could you give an example of what you want? The above description is not very clear.
 
Old 05-24-2010, 06:13 AM   #3
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 14,848

Rep: Reputation: 1823Reputation: 1823Reputation: 1823Reputation: 1823Reputation: 1823Reputation: 1823Reputation: 1823Reputation: 1823Reputation: 1823Reputation: 1823Reputation: 1823
Even better - show us what you have attempted, and why you need help.
 
Old 05-24-2010, 06:19 AM   #4
ajeetsinghraina
Member
 
Registered: May 2010
Location: India
Distribution: Ubuntu 7.04/8.04/8.10/10.04, RHEL 6, OpenSUSE,Mandriva,Fedora, CentOS, XandrOS, Slackware, OpenSolar
Posts: 155

Rep: Reputation: 55
grep "98782" <filename>
 
Old 05-25-2010, 07:20 AM   #5
sushil.cool
LQ Newbie
 
Registered: Mar 2010
Posts: 15

Original Poster
Rep: Reputation: 0
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.
 
Old 05-25-2010, 07:23 AM   #6
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387
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.
 
Old 05-25-2010, 07:27 AM   #7
linuxlover.chaitanya
Senior Member
 
Registered: Apr 2008
Location: Nagpur, India
Distribution: Cent OS 5/6, Ubuntu Server 10.04
Posts: 4,629

Rep: Reputation: Disabled
grep ^9872 <filename>

Edit: druuna beat on this.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Trying to understand pipes - Can't pipe output from tail -f to grep then grep again lostjohnny Linux - Newbie 15 03-12-2009 11:31 PM
2.4 series vs 2.6 series (Kernels) Tux-Slack Linux - General 1 06-01-2007 03:27 PM
grep output on stdout and grep output to file don't match xnomad Linux - General 3 01-13-2007 05:56 AM
What is the difference between an i-series and a p-series machine? subendu Linux - Hardware 1 09-07-2006 10:51 AM
ps -ef|grep -v root|grep apache<<result maelstrombob Linux - Newbie 1 09-24-2003 12:38 PM


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

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration