LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
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 11-12-2008, 05:13 AM   #1
shariefbe
Member
 
Registered: Aug 2008
Location: Tiruchirappalli, India
Distribution: UBUNTU 11.04
Posts: 368

Rep: Reputation: 31
using grep and find command


hello,

i am new to linux....i dont know how to use "grep" command and "find" command...i searched in internet..but cant find the solution clearly...can anyone help me...what is the syntax to find the files using "find" command and find pattern using "grep" command.....Thanks in advance.
 
Old 11-12-2008, 05:23 AM   #2
angel115
Member
 
Registered: Jul 2005
Location: France / Ireland
Distribution: Debian mainly, and Ubuntu
Posts: 528

Rep: Reputation: 78
Hi shariefbe,

Here would be an example to find all file named "test.txt"
Code:
find / -type f -iname "test.txt"
The following code will search for all file or directory containing "test"
but will display only the string containing "test.txt"
Code:
find / -iname "test" |grep "test.txt"
PS: when you don't know how to use a command you can use "man $command_name"
Ex:
Code:
man find

Last edited by angel115; 11-12-2008 at 05:25 AM.
 
Old 11-13-2008, 03:51 AM   #3
shariefbe
Member
 
Registered: Aug 2008
Location: Tiruchirappalli, India
Distribution: UBUNTU 11.04
Posts: 368

Original Poster
Rep: Reputation: 31
yes...i got it...now understood...thanks a lot....
 
Old 11-13-2008, 03:54 AM   #4
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 670Reputation: 670Reputation: 670Reputation: 670Reputation: 670Reputation: 670
Both commands have info pages. The fundamental difference is that find is used to locate files with a certain criteria. Grep is used to locate lines of text inside of a file (or files) matching a certain regular expression.

Grep is great for filtering the output of other commands, like locate.
 
Old 11-13-2008, 03:58 AM   #5
Davinder Singh
LQ Newbie
 
Registered: Sep 2006
Posts: 11

Rep: Reputation: 0
grep is used to pick any work from file
like
history | grep cp
it will show all commands where u used cp
 
Old 04-01-2009, 09:27 AM   #6
sathiyamoorthy
Member
 
Registered: Feb 2008
Posts: 32

Rep: Reputation: 15
Arrow

traffic driving links removed

Last edited by Tinkster; 04-01-2009 at 12:01 PM.
 
  


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
Find/grep command to find matching files, print filename, then print matching content stefanlasiewski Programming 9 06-30-2016 06:30 PM
Grep V/s Find justmovedtolinux Programming 3 10-02-2008 04:29 AM
Help me in Grep Command + cd command in single line JeiPrakash Linux - Newbie 3 05-27-2008 05:16 AM
Command line tool to find(1) or grep(1) faster? rsheridan6 Linux - Software 2 02-18-2006 04:50 PM
Help me to understand this command: find...| grep -e ... | xargs rm -f ROBERT483599 Red Hat 2 02-14-2006 09:21 AM


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