The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Advanced & Expert Users
.
google unix.com



UNIX for Advanced & Expert Users Expert-to-Expert. Learn advanced UNIX, UNIX commands, Linux, Operating Systems, System Administration, Programming, Shell, Shell Scripts, Solaris, Linux, HP-UX, AIX, OS X, BSD.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
making a recursive find more useful.. spanish_tony UNIX for Dummies Questions & Answers 3 03-14-2007 05:48 AM
find file with date and recursive search for a text rosh0623 UNIX for Advanced & Expert Users 10 08-16-2006 02:27 PM
Question: non-recursive find syntax alexkav UNIX for Dummies Questions & Answers 6 03-10-2005 07:46 AM
command find returned bash: /usr/bin/find: Argument list too long yacsil Shell Programming and Scripting 1 12-15-2003 06:38 PM
Performing a non-recursive find in Unix christallott UNIX for Advanced & Expert Users 3 09-06-2002 09:13 AM

Reply
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 06-10-2008
Nagapandi Nagapandi is offline
Registered User
  
 

Join Date: Jun 2008
Posts: 36
Non recursive find command

Hi,

I have question is related to find command. I want to find command should search in current folder only not recursive mode(sub-folders).

I found a one way of,
find . \( -name success -prune \) -o -name "Rajini*"

How ever, my current folder is having lots sub-folders and am not interested to give all sub-folders names with find command.

Waiting for your valuable reply.

Thanks,
Naga
  #2 (permalink)  
Old 06-10-2008
era era is offline Forum Advisor  
Herder of Useless Cats (On Sabbatical)
  
 

Join Date: Mar 2008
Location: /there/is/only/bin/sh
Posts: 3,652
If you don't want recursion, is find even the right command?

Code:
echo Rajini*
Some versions of find have a -maxdepth option which allow you to control how deep into subdirectories it will recurse. With -maxdepth 1 it will only search the current directory.
  #3 (permalink)  
Old 06-10-2008
Nagapandi Nagapandi is offline
Registered User
  
 

Join Date: Jun 2008
Posts: 36
Thanks for your reply.

As you know, simple find by default recrusive option is true. As you quoted, i tried -maxdepth, how ever it's not working with my OS.

PFB details, (am using SunOS 5.9)

> find . -name "Rajini*" -maxdepth 1
find: bad option -maxdepth
find: path-list predicate-list

Is there any other apart from -maxdepth?

Waiting for your valuable reply

Thanks,
Naga
  #4 (permalink)  
Old 06-10-2008
era era is offline Forum Advisor  
Herder of Useless Cats (On Sabbatical)
  
 

Join Date: Mar 2008
Location: /there/is/only/bin/sh
Posts: 3,652
You can feed the output of find to grep, but that won't prevent it from going recursive, just remove the subdirectories from the output (which is a problem if you want to avoid the overhead of recursive processing, but perhaps acceptable if that's not the problem you are trying to solve).

I'm still thinking you should not be using find in the first place, though.
  #5 (permalink)  
Old 06-10-2008
Nagapandi Nagapandi is offline
Registered User
  
 

Join Date: Jun 2008
Posts: 36
Thanks.

-Naga
  #6 (permalink)  
Old 06-10-2008
shamrock shamrock is offline Forum Advisor  
Registered User
  
 

Join Date: Oct 2007
Location: USA
Posts: 750
I concur with era...the echo command is ideal for your scenario and from your post it seems that you have a find one-liner.
  #7 (permalink)  
Old 06-10-2009
fenugreek fenugreek is offline
Registered User
  
 

Join Date: Jun 2009
Posts: 1
Try this

find /folder/* -prune -type f -name 'Rajini*'

This works for me on a Solaris system
Reply

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 11:32 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0