LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
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 03-20-2006, 01:48 PM   #1
bashhh
LQ Newbie
 
Registered: Mar 2006
Posts: 2

Rep: Reputation: 0
Linux Script Question


I need to know the difference between the two commands bellow and what exactly they doing.


find ~ -type f -exec grep -l $1 {} \;

find $HOME -type f -exec grep -l $1 {} \;


Thank you very much
 
Old 03-20-2006, 01:51 PM   #2
ckoniecny
Member
 
Registered: Oct 2005
Posts: 162

Rep: Reputation: 30
Well $HOME is a variable, it can be changed where "~" cannot be changed. I would use the "~" command over the $HOME because $HOME can be changed and cause problems in the future.
 
Old 03-20-2006, 01:52 PM   #3
bashhh
LQ Newbie
 
Registered: Mar 2006
Posts: 2

Original Poster
Rep: Reputation: 0
What is the purpose of -l.
Can u explain the whole function of the command step by step?
Thank you.-
 
Old 03-20-2006, 01:58 PM   #4
ckoniecny
Member
 
Registered: Oct 2005
Posts: 162

Rep: Reputation: 30
If you do a "man grep" you will see what the options for "grep" does. The "l" option lists found items like below.

"-type f" = regular file
"-exec grep -l cpp {} \;" = this basically says, if find finds any files, look inside of the file for the string "cpp" and list them.

(%:~)- find ~ -type f -exec grep -l cpp {} \;
/home/test/C++/Makefile
/home/test/C++/pointer

If you have a question on what a option does for a command, just type "man command".

Last edited by ckoniecny; 03-20-2006 at 01:59 PM.
 
  


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
linux script question: data bhuwan Linux - Software 3 02-21-2006 11:14 AM
A simple Linux script question I'm sure Tap-Out Programming 4 07-23-2005 02:11 PM
Question about Bash script for Linux Linh Programming 9 04-21-2004 11:54 AM
script question shanenin Linux - Software 2 04-04-2004 10:39 AM
linux 9 and java script error - premature end of script header sibil Linux - Newbie 0 01-06-2004 04:21 PM

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

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