LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 05-09-2007, 02:10 PM   #1
666
Member
 
Registered: May 2005
Distribution: Debian
Posts: 37

Rep: Reputation: 16
How to search within text file


Hi,

I received a few hundred pages text file. Each line consist with a name, address, city etc. Since they are in alphabetical order I have a problem because I would like to list only the entries from a particular city for example.
How could I list only the lines which fits a given keyword?

Thanks
 
Old 05-09-2007, 02:11 PM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
that'd be grep.

grep mytown file.txt
 
Old 05-09-2007, 02:26 PM   #3
666
Member
 
Registered: May 2005
Distribution: Debian
Posts: 37

Original Poster
Rep: Reputation: 16
I do not have a habit asking questions without trying to resolve it myself but it is a work related issue and I am in a hurry.
You saved me a lot of time today.

Thank you!
 
  


Reply



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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Need command to search and replace text in file acascianelli AIX 12 04-11-2007 08:16 PM
search / count unique patterns in text file logicalfuzz Linux - Newbie 2 10-14-2006 07:58 AM
Which command to search text/phrase in file? b:z Linux - General 2 03-30-2005 09:11 PM
Need to search for *last* occurrance in a text file ericcarlson Linux - Software 1 09-11-2004 02:08 PM
How do you search for a file in text mode? cyberkid12 Linux - General 7 12-21-2002 12:42 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 06:06 AM.

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
Open Source Consulting | Domain Registration