LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
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-14-2001, 07:41 PM   #1
philfighter
Member
 
Registered: Apr 2001
Location: South of Atlanta
Distribution: Mandrake 8.1, Suse 7.0
Posts: 207

Rep: Reputation: 30

what is the command "grep" used for?
 
Old 05-14-2001, 08:12 PM   #2
rshaw
Senior Member
 
Registered: Apr 2001
Location: Perry, Iowa
Distribution: Mepis , Debian
Posts: 2,692

Rep: Reputation: 45
it's used to search files for words, words strings or what ever
 
Old 05-15-2001, 06:11 AM   #3
philfighter
Member
 
Registered: Apr 2001
Location: South of Atlanta
Distribution: Mandrake 8.1, Suse 7.0
Posts: 207

Original Poster
Rep: Reputation: 30
is it used like "whereis"?
 
Old 05-15-2001, 06:45 AM   #4
Dallam
Member
 
Registered: Apr 2001
Location: England
Distribution: SuSE 7.1
Posts: 63

Rep: Reputation: 15
Hi,
Grep searches one or more input files for lines containing a match to a specified pattern. By default, grep prints the matching lines.
Dallam
 
Old 05-15-2001, 02:50 PM   #5
KevinJ
Member
 
Registered: Feb 2001
Location: Colorado Springs, CO
Distribution: Redhat v8.0 (soon to be Fedora? or maybe I will just go back to Slackware)
Posts: 857

Rep: Reputation: 30
Talking

go to a command prompt and type:

'man grep'

then try

'man whereis'

 
Old 05-16-2001, 05:00 AM   #6
philfighter
Member
 
Registered: Apr 2001
Location: South of Atlanta
Distribution: Mandrake 8.1, Suse 7.0
Posts: 207

Original Poster
Rep: Reputation: 30
man pages?

look, if yur going to just tell me to look at the man pages etc dont bother else i wouldnt come to this forum to ask...
 
Old 05-16-2001, 05:17 AM   #7
Dallam
Member
 
Registered: Apr 2001
Location: England
Distribution: SuSE 7.1
Posts: 63

Rep: Reputation: 15
hi,
try these out:

grep foo file returns all the lines that contain a string matching the expression "foo" in the file "file".

ls |grep blah lists all files in the current directory containing the string "blah"

try doing a search on grep and see all the info it turns up.There are pages and pages of information out there on grep and the commands.
Dallam
 
Old 05-16-2001, 10:23 AM   #8
KevinJ
Member
 
Registered: Feb 2001
Location: Colorado Springs, CO
Distribution: Redhat v8.0 (soon to be Fedora? or maybe I will just go back to Slackware)
Posts: 857

Rep: Reputation: 30
Well, frankly, if you aren't willing to read the man pages first, then you probably shouldn't waste other folks time with your questions.

Your question: "What is grep used for?"

From the man page for grep:
"Grep searches the named input FILEs (or standard input if no files are named, or the file name - is given) for lines containing a match to the given PATTERN. By default, grep prints the matching lines."

Your question: "Is it used like whereis?"

From the man page for whereis:
"whereis locates source/binary and manuals sections for
specified files. The supplied names are first stripped of
leading pathname components and any (single) trailing
extension of the form .ext, for example, .c. Prefixes of
s. resulting from use of source code control are also
dealt with. whereis then attempts to locate the desired
program in a list of standard Linux places." (so the clear inference would be "NO, its not used like whereis")


I am gonna go out on a limb and say that everyone that regularly participates in this forum does so out of a genuine interest in helping others. I don't think its too much to ask that someone read the documentation that comes with a product.

 
Old 05-17-2001, 07:28 PM   #9
philfighter
Member
 
Registered: Apr 2001
Location: South of Atlanta
Distribution: Mandrake 8.1, Suse 7.0
Posts: 207

Original Poster
Rep: Reputation: 30
well, just an opinion but i think it is a timewaster for me personally, as i have always learned far better when a person explains things to me in layman's terms. sorry for being so dyslexic...
 
Old 05-17-2001, 07:57 PM   #10
notlinus
Member
 
Registered: May 2001
Location: Kingsport, TN
Distribution: RedHat 6.1
Posts: 61

Rep: Reputation: 15
Red face

Assuming you are coming from Windows (probably most of us did) - it's like the Find command on the Start menu. The commands Find and Whereis are like if you put text in the "Named" box - they find filenames. Grep is like if you put text in the "Containing text" box - it finds files that contain the text specified. Very useful if you are looking for that great recipe that used kiwi, but can't remember where the file is or what it was called...
/js
 
  


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
Is there a single command to list all hardware installed (command line)? davee Linux - Hardware 6 02-28-2009 07:19 PM
Command to output file content line by line aznluvsmc Programming 2 09-12-2004 07:45 PM
51 characters only in the 1st Line of command line eggCover Linux - General 2 07-29-2004 01:28 PM
Command to display whole filestructure hierarchy f/ command line? mjewell Linux - Newbie 10 01-19-2004 10:48 AM
Where is Command line utility for Cups and command tutorial mossy Linux - Software 8 01-16-2004 12:24 AM

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

All times are GMT -5. The time now is 06:19 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