- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: non-recursive find
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
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
тАО02-04-2010 07:06 AM
тАО02-04-2010 07:06 AM
I would like to run:
find . -type f -mtime +30 -exec /bin/rm {} \;
only in the current directory without subdirectories. I can't see such an option in find manual of AIX 5.3. Any ideas how I can handle it?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-04-2010 07:22 AM
тАО02-04-2010 07:22 AM
Re: non-recursive find
Try the option prune
find . -type f -prune -mtime +30 -print
HTH
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-04-2010 07:31 AM
тАО02-04-2010 07:31 AM
Solution# cd /path
# find . \( -type f -o -name . -o -prune \) -a -mtime +30 -a -exec ls -ld {} +
If you like the results, change 'ls -ld {} +' to 'rm {} +'.
Using the '+' terminator with '-exec' is much faster since multiple arguments are passed to the spawned process.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-04-2010 08:04 AM
тАО02-04-2010 08:04 AM
Re: non-recursive find
So why ask here?
> Using the '+' terminator [...]
May not work well with the "find" program on
AIX 5.3, but I haven't tried it.
A Forum search for keywords like
find prune
may find more examples. GNU "find" has a
"-maxdepth" option, which may be easier to
use (or understand), and GNU "find" should
be available for AIX.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-04-2010 09:16 AM
тАО02-04-2010 09:16 AM
Re: non-recursive find
I should have written the following to avoid listing subdirectories in the first place:
# find . \( -name . -o -prune \) -type f -mtime +30 -exec ls -ld {} +
I also eliminated the implicit "and" ('-a') for bevity.
Yes, using the '+' terminator works on AIX ( >= 5.2 at least).
Yes, one wishes the HP-UX (and AIX) had the GNU '-maxdepth' option.
And, just maybe the OP has use for this in a script that runs on many flavors of UNIX let alone LINUX...
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-08-2010 09:02 AM
тАО02-08-2010 09:02 AM
Re: non-recursive find
Please explain the use of -o in the syntax,
Thanks...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-08-2010 09:42 AM
тАО02-08-2010 09:42 AM
Re: non-recursive find
> Please explain the use of -o in the syntax,
The '-o' means "or. An '-a' means "and". see the manpages for 'find()'.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-08-2010 09:45 AM
тАО02-08-2010 09:45 AM
Re: non-recursive find
Yes, thanks! I can see that - In fact, had looked at the man page before posting, but it made no sense reviewing this thread, but for some reason, now it does.
Thanks!
RCP