Operating System - HP-UX
1819876
Members
2550
Online
109607
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
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
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
тАО11-06-2008 06:08 AM
тАО11-06-2008 06:08 AM
xdev
Hi,
How xdev and xargs helpful in scripting. how its working. What is the use of it. Pls explain
Reagrds
Rkumar
How xdev and xargs helpful in scripting. how its working. What is the use of it. Pls explain
Reagrds
Rkumar
2 REPLIES 2
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-06-2008 06:19 AM
тАО11-06-2008 06:19 AM
Re: xdev
Hi:
I assume that by 'xdev' you mean the '-xdev' option of 'find'. This option prevents 'find' from crossing mountpoints. This is extremely useful when you truly want to only search the root filesystem, as in:
# find / -xdev -type f -mtime -30
...which would find files modifed during the last 30-days.
In the case of 'xargs' is seen in pipelines to construct lists of things on which execution is performed. Since 'xargs' can collect multiple arguments into a list of arguments it can be used to greatly reduce the number of processes that you need to spawn. A classic example of this is again with 'find'. Consider:
# find / -xdev -type f -mtime -30 -exec ls -l {} \;
...This spawns an 'ls' command for *every* file found (and therefore becomes costly).
# find / -xdev -type f -mtime -30 | xargs ls -l {}
...spawns only one or very few processes depending on the argument list size making this very efficient.
Now, in truth, 'find' has a newer syntax with its '-exec' that accomplishes the same thing as an 'xargs' pipe:
# find / -xdev -type f -mtime -30 -exec ls -l {} +
The "+' instead of the escaped ";" triggers 'find's inbuilt buffering.
Regards!
...JRF...
I assume that by 'xdev' you mean the '-xdev' option of 'find'. This option prevents 'find' from crossing mountpoints. This is extremely useful when you truly want to only search the root filesystem, as in:
# find / -xdev -type f -mtime -30
...which would find files modifed during the last 30-days.
In the case of 'xargs' is seen in pipelines to construct lists of things on which execution is performed. Since 'xargs' can collect multiple arguments into a list of arguments it can be used to greatly reduce the number of processes that you need to spawn. A classic example of this is again with 'find'. Consider:
# find / -xdev -type f -mtime -30 -exec ls -l {} \;
...This spawns an 'ls' command for *every* file found (and therefore becomes costly).
# find / -xdev -type f -mtime -30 | xargs ls -l {}
...spawns only one or very few processes depending on the argument list size making this very efficient.
Now, in truth, 'find' has a newer syntax with its '-exec' that accomplishes the same thing as an 'xargs' pipe:
# find / -xdev -type f -mtime -30 -exec ls -l {} +
The "+' instead of the escaped ";" triggers 'find's inbuilt buffering.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-06-2008 06:43 AM
тАО11-06-2008 06:43 AM
Re: xdev
Hi,
xdev:
xdev is to restrict search not to cross mount points. Default search will do it on mount points as well.
For example if you want to search only on / and not to seach /var, /etc, etc then you need to specify xdev
#find / -xdev -name *.txt -print
xargs:
when you use -exec to pipe the output of find command to perform something else,
-exec will start a new process for each line of the output. Sometime -exec may not be able to handle this and command seems to be hung. xargs handle this perfectly. It will start only limited process
#find / -user abc |xargs rm -rf {}
xdev:
xdev is to restrict search not to cross mount points. Default search will do it on mount points as well.
For example if you want to search only on / and not to seach /var, /etc, etc then you need to specify xdev
#find / -xdev -name *.txt -print
xargs:
when you use -exec to pipe the output of find command to perform something else,
-exec will start a new process for each line of the output. Sometime -exec may not be able to handle this and command seems to be hung. xargs handle this perfectly. It will start only limited process
#find / -user abc |xargs rm -rf {}
Best wishes,
Ganesh.
Ganesh.
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.
Company
Learn About
News and Events
Support
© Copyright 2025 Hewlett Packard Enterprise Development LP