|
|
public
|
|
Dec 19, 2006 01:34:29 GMT
|
|
I want to use "find" command ,only search in the current directory,not include the sub-directory.
how can I do?
|
|
|
Note: If you are the author of this question and wish to assign points to any of the answers, please login first.For more information on assigning points ,click
here
|
|
|
Sort Answers By:
Date or Points
|
|
Yogeeraj
|
|
Dec 19, 2006 01:45:46 GMT
Unassigned
|
|
hi,
I can't find any switch in the find command for this purpose.
maybe you can instead use:
ls -al |grep <file to find>
maybe others have a better solution
kind regards yogeeraj |
|
Senthil Prabu.S
|
|
Dec 19, 2006 04:21:23 GMT
Unassigned
|
|
Hi, Yes, you can do it using "depth" switch. On my linux machine, I can parse only on current dir, not on its sub-dir with this command;
#find . -maxdepth 1
where, 1 is the depth of dir to parse....
I am not sure this switch works on HP-UX.
Note: I dont have a HP mac to test it.
HTH, Prabu.S |
|
|
Stanislav Bocinec
|
|
Dec 19, 2006 04:58:14 GMT
Unassigned
|
|
and is there a necessity of using find command? if you want to find only in current dir,i would use combination of 'ls' and 'grep' command,e.g. ls -al|grep "what u want" ;) s. |
|
Peter Godron
|
|
Dec 19, 2006 05:12:27 GMT
Unassigned
|
|
Hi, not the nicest solution, but this may work: # Produce a list of direct sub-directories ls -p1 | grep -e'/' > a.lis # Get list of files, but exclude all direct sub-directories find . | egrep -v -f a.lis
example: I have two files called a.c, one in current and one in test sub-directory $ find . -name a.c ./a.c ./test/a.c
$ ls -p1 | grep -e'/' > a.lis $ find . -name a.c | egrep -v -f a.lis ./a.c
Only the current a.c is found ! |
|
lawrenzo
|
|
Dec 19, 2006 05:33:03 GMT
Unassigned
|
|
find -prune works on AIX but not sure on HP.
from the man page:
-prune Always evaluates to the value True. Stops the descent of the current path name if it is a directory. If the -depth flag is specified, the -prune flag is ignored. |
|
James R. Ferguson
|
|
Dec 19, 2006 07:26:07 GMT
Unassigned
|
|
Hi:
Well, you could do the following. The example assumes that you want to find all *files* that begin with the letter "p" in the working directory:
# cd /pathname # find . -type f -name "p*" ! -path "./*/*"
Regards!
...JRF... |
|
Raj D.
|
|
Dec 19, 2006 10:00:48 GMT
Unassigned
|
|
Public,
You can use the -xdev option if pointing to a mount point directory ,
Cheers, Raj. |
|
Sp4admin
|
|
Dec 19, 2006 13:59:45 GMT
Unassigned
|
|
Hi
just cd into the directory you want to look in and do "find . -name filename" or to chek the whole system do "find / -name filename"
sp, |
|
Jonathan Fife
|
|
Dec 19, 2006 14:05:11 GMT
Unassigned
|
|
I use:
find . \( -type d ! -name . -prune \) -o \( <search terms> -print \) |
|
Sandman!
|
|
Dec 19, 2006 14:24:23 GMT
Unassigned
|
|
To see all files in the current folder w/o searching any sub-directories:
# find . -path "./*" -prune -type f
To see all files and sub-dirs in the current dir (without going into any sub-dir) remove the "-type" option to the above find command, i.e.
# find . -path "./*" -prune
~hope it helps |
|
TwoProc
|
|
Dec 19, 2006 14:36:00 GMT
Unassigned
|
|
One more - much like the above one:
find * .* -prune |
|
TwoProc
|
|
Dec 19, 2006 15:18:27 GMT
Unassigned
|
|
Just for fun,
I kept fooling with this idea and got a neater output - which is funny enough - almost like "ls -a 1". It takes JRF's output and removes the leading "./*"
find . -path "./*" -prune -exec basename {} \;
I liked the output, but I didn't like how the hidden files (files starting with ".") didn't come out first, so I sorted them to get that "almost ls" look.
find . -path "./*" -prune -exec basename {} \; | sort
Of course, as noted before - by adding "-type f" or "-type d" to the find command returns just files or directories, respectively. |
|