- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: how to use "find" command
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-18-2006 05:34 PM
тАО12-18-2006 05:34 PM
how to use "find" command
how can I do?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-18-2006 05:45 PM
тАО12-18-2006 05:45 PM
Re: how to use "find" command
I can't find any switch in the find command for this purpose.
maybe you can instead use:
ls -al |grep
maybe others have a better solution
kind regards
yogeeraj
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-18-2006 08:21 PM
тАО12-18-2006 08:21 PM
Re: how to use "find" command
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-18-2006 08:58 PM
тАО12-18-2006 08:58 PM
Re: how to use "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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-18-2006 09:12 PM
тАО12-18-2006 09:12 PM
Re: how to use "find" command
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 !
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-18-2006 09:33 PM
тАО12-18-2006 09:33 PM
Re: how to use "find" command
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-18-2006 11:26 PM
тАО12-18-2006 11:26 PM
Re: how to use "find" command
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...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-19-2006 02:00 AM
тАО12-19-2006 02:00 AM
Re: how to use "find" command
You can use the -xdev option if pointing to a mount point directory ,
Cheers,
Raj.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-19-2006 05:59 AM
тАО12-19-2006 05:59 AM
Re: how to use "find" command
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,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-19-2006 06:05 AM
тАО12-19-2006 06:05 AM
Re: how to use "find" command
find . \( -type d ! -name . -prune \) -o \(
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-19-2006 06:24 AM
тАО12-19-2006 06:24 AM
Re: how to use "find" command
# 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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-19-2006 06:36 AM
тАО12-19-2006 06:36 AM
Re: how to use "find" command
find * .* -prune
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-19-2006 07:18 AM
тАО12-19-2006 07:18 AM
Re: how to use "find" command
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.