- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Find command
Operating System - HP-UX
1753758
Members
4982
Online
108799
Solutions
Forums
Categories
Company
Local Language
юдл
back
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
юдл
back
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
Blogs
Information
Community
Resources
Community Language
Language
Forums
Blogs
Go to solution
Topic Options
- 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
тАО05-31-2011 02:21 AM
тАО05-31-2011 02:21 AM
Hi, I'm new to UNIX..
Could you please explain me what does the below find command execute?
find /home -xdev -type f -name core -exec ls -ld {}\;
Could you please explain me what does the below find command execute?
find /home -xdev -type f -name core -exec ls -ld {}\;
Solved! Go to Solution.
2 REPLIES 2
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-31-2011 03:17 AM
тАО05-31-2011 03:17 AM
Solution
> find /home -xdev -type f -name core -exec ls -ld {}\;
This command looks through the /home directory (and sub-directories) looking for a file named "core" and if found, shows the file with an ls -d command.
Here are the details:
/home = starting directory
-xdev = do not cross any moutpoints within /home. A mountpoint could be an NFS mount from another system or another logical volume (lvol).
-type f = locate only ordinary files, not directories or symlinks, etc
-name core = match only files named "core"
-exec ls -ld = when a match is found run the command ls -ld on the file
{} = a placeholder where the filename would be required for ls -ld
\; = the exec option needs the command line terminated with either \; or +
The man page for find covers all these details.
Bill Hassell, sysadmin
This command looks through the /home directory (and sub-directories) looking for a file named "core" and if found, shows the file with an ls -d command.
Here are the details:
/home = starting directory
-xdev = do not cross any moutpoints within /home. A mountpoint could be an NFS mount from another system or another logical volume (lvol).
-type f = locate only ordinary files, not directories or symlinks, etc
-name core = match only files named "core"
-exec ls -ld = when a match is found run the command ls -ld on the file
{} = a placeholder where the filename would be required for ls -ld
\; = the exec option needs the command line terminated with either \; or +
The man page for find covers all these details.
Bill Hassell, sysadmin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-31-2011 03:18 AM
тАО05-31-2011 03:18 AM
Re: Find command
Add "echo" after -exec and it will just display the command lines it would execute, instead of actually executing them:
find /home -xdev -type f -name core -exec echo ls -ld {}\;
Your original command will go through /home and all the sub-directories of /home that are within the same filesystem (i.e. it will not cross mount points, because of the -xdev option).
It will look for regular files (option -type f) named "core" (option -name ...). For each file it finds, your command will run "ls -ld".
For example, if the /home filesystem contains files /home/kchand/project1/core, /home/luser/core and /home/joe/very/deep/directory/structure/core, then find would run the following commands:
ls -ld /home/kchand/project1/core
ls -ld /home/luser/core
ls -ld /home/joe/very/deep/directory/structure/core
MK
find /home -xdev -type f -name core -exec echo ls -ld {}\;
Your original command will go through /home and all the sub-directories of /home that are within the same filesystem (i.e. it will not cross mount points, because of the -xdev option).
It will look for regular files (option -type f) named "core" (option -name ...). For each file it finds, your command will run "ls -ld
For example, if the /home filesystem contains files /home/kchand/project1/core, /home/luser/core and /home/joe/very/deep/directory/structure/core, then find would run the following commands:
ls -ld /home/kchand/project1/core
ls -ld /home/luser/core
ls -ld /home/joe/very/deep/directory/structure/core
MK
MK
The opinions expressed above are the personal opinions of the authors, not of Hewlett Packard Enterprise. By using this site, you accept the Terms of Use and Rules of Participation.
News and Events
Support
© Copyright 2024 Hewlett Packard Enterprise Development LP