LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
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 04-17-2012, 06:46 AM   #1
muralimunna
LQ Newbie
 
Registered: Apr 2012
Posts: 4

Rep: Reputation: Disabled
find command


how can get only 2.1G,using sed and awk commands
/dev/ad0s1d 5.8G 2.1G 3.2G 4

Last edited by muralimunna; 05-02-2012 at 02:20 AM.
 
Old 04-17-2012, 06:48 AM   #2
fukawi1
Member
 
Registered: Apr 2009
Location: Melbourne
Distribution: Fedora & CentOS
Posts: 854

Rep: Reputation: 193Reputation: 193
To find a thing IN as in INSIDE a file? you dont with find.
You use grep.
Code:
grep "something" /somewhere/somefile
man grep for more information.
 
Old 04-17-2012, 07:55 AM   #3
David the H.
Bash Guru
 
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Arch + Xfce
Posts: 6,852

Rep: Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037
As said, find is for locating files based on conditions like filename and modification date, while grep is for searching inside them (assuming text files).

Here are a couple of links about using find:
http://mywiki.wooledge.org/UsingFind
http://www.grymoire.com/Unix/Find.html

You can, of course, combine them in order to locate files and then search inside them. But you should first see if you can use grep's own built-in recursive file-matching ability. Read the "info grep" page for details on how to use it.
 
Old 04-17-2012, 09:50 AM   #4
Satyaveer Arya
Senior Member
 
Registered: May 2010
Location: Palm Island
Distribution: RHEL, CentOS, Debian, Oracle Solaris 10
Posts: 1,420

Rep: Reputation: 305Reputation: 305Reputation: 305Reputation: 305
muralimunna,

Welcome to LQ!
First you need to check the man page of find and grep.
Code:
# man find
# man grep
And I think you can understand the difference between find and grep already told by fukawi1 and David the H.

Last edited by Satyaveer Arya; 04-17-2012 at 09:51 AM.
 
Old 04-17-2012, 10:41 AM   #5
pafoo
Member
 
Registered: Jul 2011
Location: Alabama
Distribution: Red Hat/Ubuntu/Solaris
Posts: 37

Rep: Reputation: 11
To help a bit more you can use find to locate files then grep for a particular item in them.

Code:
find /home/bobby -type f -name "*.txt" -exec grep "funny joke" {} \;
 
  


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



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Find a file in directories without using find command sikanders Linux - Newbie 14 08-06-2010 08:47 PM
Find/grep/wc command to find matching files, print filename and word count dbasch Linux - Newbie 10 09-14-2009 05:55 PM
Single find command to find multiple files? thok Linux - Newbie 7 01-31-2009 04:45 PM
Using a single "Find" Command to find files bases on multiple criteria roboxooo Linux - Newbie 6 01-15-2009 04:13 AM
can't find my find command! how to replace? dave247 Debian 4 11-19-2008 10:51 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

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