LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 09-29-2004, 04:13 PM   #1
saiz66
Member
 
Registered: Apr 2003
Posts: 225

Rep: Reputation: 30
[c shell] using grep


How do I find a specific word in a file using grep? And how do I output the line it is on with the line number it was found on? Any help? Thanks in advance!
 
Old 09-29-2004, 04:23 PM   #2
Bebo
Member
 
Registered: Jul 2003
Location: Göteborg
Distribution: Arch Linux (current)
Posts: 553

Rep: Reputation: 31
Use

Code:
grep -n <string> <file>
 
Old 09-29-2004, 04:36 PM   #3
saiz66
Member
 
Registered: Apr 2003
Posts: 225

Original Poster
Rep: Reputation: 30
thank you Bebo. I have a stupid question .. I want to know how you know this? Do you have a shell book or do you use man on grep? Thanks.
 
Old 09-29-2004, 04:58 PM   #4
Bebo
Member
 
Registered: Jul 2003
Location: Göteborg
Distribution: Arch Linux (current)
Posts: 553

Rep: Reputation: 31
It's all magic Nah, I just read the man pages: man grep
 
Old 09-29-2004, 05:59 PM   #5
saiz66
Member
 
Registered: Apr 2003
Posts: 225

Original Poster
Rep: Reputation: 30
thank you.
 
Old 09-30-2004, 11:12 AM   #6
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.x
Posts: 18,444

Rep: Reputation: 2791Reputation: 2791Reputation: 2791Reputation: 2791Reputation: 2791Reputation: 2791Reputation: 2791Reputation: 2791Reputation: 2791Reputation: 2791Reputation: 2791
You could also try these tutorial links on shell/Linux:
http://freeos.com/guides/lsst/
http://www.icon.co.za/~psheer/book/index.html.gz
easier on the brain than man pages
 
Old 09-30-2004, 01:45 PM   #7
saiz66
Member
 
Registered: Apr 2003
Posts: 225

Original Poster
Rep: Reputation: 30
thanks a lot.. really appreciate it.
 
  


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
Grep Syslog - email shell script voodoofxz Linux - Newbie 1 09-06-2005 04:27 PM
grep in shell script fails on redhat 3.0 rlangsto Linux - General 4 03-06-2005 07:42 PM
Shell grep issue philipz Programming 8 05-05-2004 01:50 PM
line addressing with grep (shell scripting) j2dizzo Linux - General 13 03-03-2004 09:36 AM
Shell programming - grep?? ducka Programming 15 09-05-2003 04:06 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 01:51 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
Open Source Consulting | Domain Registration