The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Explain the line "mn_code=`env|grep "..mn"|awk -F"=" '{print $2}'`" Lokesha UNIX for Dummies Questions & Answers 4 12-19-2007 10:52 PM
grep to find content in between curly braces, "{" and "}," keshav_rk Shell Programming and Scripting 4 08-09-2007 07:14 PM
Listing only directories in the current working directory using the "ls" command igandu UNIX for Dummies Questions & Answers 2 05-12-2006 01:47 AM
How to find out the exact year in "Last modified time" using ls command Dophlinne UNIX for Dummies Questions & Answers 6 04-11-2006 08:07 AM
chmod 777 on all directories below...how do I do that using the "find" command? Neko UNIX for Dummies Questions & Answers 7 07-12-2001 06:58 PM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 01-17-2006
Registered User
 

Join Date: Sep 2005
Posts: 25
"find command" to find the files in the current directories but not in the "subdir"

Dear friends,
please tell me how to find the files which are existing in the current directory, but it sholud not search in the sub directories..

it is like this,

current directory contains
file1, file2, file3, dir1, dir2

and dir1 conatins
file4, file5

and dir2 contains
file6, file7


what i need is when i am in current dir, and if use find command it shold display only
file1, file2, file3

but not others,

please help

very eager to see ur replys..


regards,
swamymns
Reply With Quote
Forum Sponsor
  #2  
Old 01-17-2006
vino's Avatar
Supporter (in vino veritas)
 

Join Date: Feb 2005
Location: Bangalore, India
Posts: 2,699
Use the search feature.

advanced/complex uses of the find command
Reply With Quote
  #3  
Old 01-17-2006
Registered User
 

Join Date: Nov 2005
Location: cyberjaya
Posts: 85
if u're using gnu find, u can use -maxdepth option
eg:
$ find . -maxdepth 1 -name file
will show file in the current dir only.
Reply With Quote
  #4  
Old 07-21-2008
Registered User
 

Join Date: Jul 2008
Posts: 10
Thumbs up vijay

find *.*
Reply With Quote
  #5  
Old 07-21-2008
Registered User
 

Join Date: Mar 2006
Posts: 41
Quote:
Originally Posted by vijayq8 View Post
find *.*
Vijay, that does not work if a sub directory name contains a ".". You may think that's uncommon, but the first time I tried your command, it failed because the directory I was in had a period!
Reply With Quote
  #6  
Old 07-22-2008
Registered User
 

Join Date: Jul 2008
Posts: 10
Thumbs up

Quote:
Originally Posted by cooldude View Post
Vijay, that does not work if a sub directory name contains a ".". You may think that's uncommon, but the first time I tried your command, it failed because the directory I was in had a period!
Hi,
it should work man, i tried in my unix box then only i posted the reply. see my result.

[mipl@subversion ~]$ ls
coding dead.letter s2.sh scripting sname sorted_names test test1 vijay
[mipl@subversion ~]$ ls -a
. .bash_profile dead.letter .kde sorted_names .viminfo
.. .bashrc .emacs s2.sh test .xemacs
.bash_history .canna .emacs.d scripting test1 .zshrc
.bash_logout coding .gtkrc sname vijay
[mipl@subversion ~]$ find *.*
dead.letter
s2.sh
[mipl@subversion ~]$

Hope you clear now.

Thanks & Regards
Vijay.
Reply With Quote
  #7  
Old 07-22-2008
Registered User
 

Join Date: Jul 2008
Location: Texas
Posts: 60
Quote:
Originally Posted by vijayq8 View Post
Hi,
it should work man, i tried in my unix box then only i posted the reply. see my result.

Hope you clear now.

Thanks & Regards
Vijay.
But, in fact, it doesn't work. Rather, it doesn't do what the original poster asked. It suffers from at least two problems.
1) If there is a sub-directory with a "." in the name, then it will search that sub-directory.
2) It will not find files that do not contain a "." in the name. It is very common for file names not to be of the form x.y.
Reply With Quote
Google The UNIX and Linux Forums
Reply

Tags
solaris

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 08:55 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0