"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

Use the search feature.

advanced/complex uses of the find command

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.

find *.*:b:

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.:b:

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.

Vijay, that does not work if a period is in the middle. See the following:

/tmp/tmp> ls -l
total 16
drwxr-xr-x   2   common       240 Jul 22 09:42 asdf.jkl
-rw-r--r--   1   common         0 Jul 22 09:40 one
-rw-r--r--   1   common         0 Jul 22 09:40 two
/tmp/tmp>
/tmp/tmp> find . *.*
.
./one
./two
./asdf.jkl
./asdf.jkl/three
./asdf.jkl/four
asdf.jkl
asdf.jkl/three
asdf.jkl/four
/tmp/tmp>
/tmp/tmp> find *.*
asdf.jkl
asdf.jkl/three
asdf.jkl/four

Again, you may think this is uncommon, but what you suggested did not work the first time I tried it in the directory I was already working in!

Typical would be:

find . -maxdepth 1 -type f

Drop the "-type f" if you want the directories to be listed.

Alternately, if you also want symlinks, pipes and the other folderol:

find . -maxdepth 1 -not -type d

BMDan, maxdepth is not standard; it only works on GNU find. My Solaris workstation does not have GNU find. Instead, a variation of a command posted by Perderabo should be used:

find . \( ! -name . -prune ! -type d \)

I think this covers all the cases.