Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers


UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 07-10-2012
Registered User
 
Join Date: Jan 2009
Posts: 213
Thanks: 6
Thanked 0 Times in 0 Posts
About find

I have three question about find

1)regardless if it can "find" something or not, the "find" will return 0,how can we use "if" to judge not find or find?

for example
#find bin/ -name bla.c
1)find it will return 0
2) not found it will return 0

the question is how can I use "if" in the bash to judge it find or not

2)can we find in something specific directory(bin,/usr/bin)

eg:I want find the bla.c only in the "bin" and "/usr/bin"

3)can we find something not in some directory(bin,/usr/bin)

eg:I want find the bla.c not in the "bin" and "/usr/bin"

Last edited by yanglei_fage; 07-10-2012 at 09:45 AM..
Sponsored Links
    #2  
Old 07-10-2012
Registered User
 
Join Date: Oct 2011
Posts: 16
Thanks: 1
Thanked 1 Time in 1 Post
> 1)regardless if it can "find" something or not, the "find" will return 0,how can
> we use "if" to judge not find or find?

You need to be more specific on what you mean here. To find something or not something, just use grep


> 2)can we find in something specific directory(bin,/usr/bin)

Yes

> 3)can we find something not in some directory(bin,/usr/bin)

Again, you need to be more specific on what you mean here. To find something or not something, just use grep
Sponsored Links
    #3  
Old 07-10-2012
vbe's Avatar
vbe vbe is offline Forum Staff  
Moderator
 
Join Date: Sep 2005
Location: Switzerland - GE
Posts: 4,633
Thanks: 118
Thanked 256 Times in 245 Posts
1) You must be kidding... (ok - answer : Yes...)

2 and 3 are answered in the man pages...
    #4  
Old 07-10-2012
Registered User
 
Join Date: Jan 2009
Posts: 213
Thanks: 6
Thanked 0 Times in 0 Posts
Close this post
Thanks
Sponsored Links
    #5  
Old 07-10-2012
zaxxon's Avatar
zaxxon zaxxon is online now Forum Staff  
code tag tagger
 
Join Date: Sep 2007
Location: St. Gallen, Switzerland
Posts: 5,872
Thanks: 80
Thanked 372 Times in 351 Posts
It doesn't work this way. You can't just open up another thread with the same questions when you are not satisfied with the answers here in hoping to get other or better answers.
It would be helpful if you maybe answer to the statements being made or rephrase your questions.
Sponsored Links
    #6  
Old 07-10-2012
vbe's Avatar
vbe vbe is offline Forum Staff  
Moderator
 
Join Date: Sep 2005
Location: Switzerland - GE
Posts: 4,633
Thanks: 118
Thanked 256 Times in 245 Posts
Quote:
for example
#find bin/ -name bla.c
1)find it will return 0
2) not found it will return 0
look:

Code:
n12:/home/vbe $ find bin/ -name bla.c
n12:/home/vbe $                               # <- empty: nothing found
n12:/home/vbe $ find bin/ -name prn  
bin/prn                                             # found!

dont confuse return code (exit value...) and what the command returns (result of the search using find...)
Sponsored Links
    #7  
Old 07-10-2012
vbe's Avatar
vbe vbe is offline Forum Staff  
Moderator
 
Join Date: Sep 2005
Location: Switzerland - GE
Posts: 4,633
Thanks: 118
Thanked 256 Times in 245 Posts
Here is the case of return code that isnt 0:

Code:
aco $ find ./home/oracle/.dt/Desktop -name toto;echo $?
find: cannot open ./home/oracle/.dt/Desktop
1


Last edited by vbe; 07-10-2012 at 10:58 AM.. Reason: color...
Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Find Failing on directory with spaces in directory name Find xargs sed errors. Find and replace. sipeki UNIX for Dummies Questions & Answers 28 04-08-2012 05:35 PM
find: missing argument to `-exec' while redirecting using find in perl ramkumarselvam Shell Programming and Scripting 2 12-16-2011 06:48 PM
Simplified find command to find multiple file types vickramshetty Linux 2 05-28-2010 01:28 PM
how to find a file named vijay in a directory using find command amirthraj_12 UNIX for Dummies Questions & Answers 6 10-25-2008 12:37 PM
command find returned bash: /usr/bin/find: Argument list too long yacsil Shell Programming and Scripting 1 12-15-2003 05:38 PM



All times are GMT -4. The time now is 03:58 AM.