- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Simple question about eliminating files!
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-16-2002 05:26 AM
тАО02-16-2002 05:26 AM
I have used the command "find /directory/filepattern -mtime +days -print -exec rm -f {} \;"
However, when I try this one the message I get is "/usr/bin/find: arg list too long". The number of files meeting the pattern given is very (I mean very) long.
What other command may I use that will not care about the number of files found?
Thanks,
ADAM
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-16-2002 06:04 AM
тАО02-16-2002 06:04 AM
Re: Simple question about eliminating files!
"find /dir/subdir -name "*filepattern*" -mtime +daysold -print -exec rm -f {} \;
This seems to work, other ways to do it?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-16-2002 09:28 AM
тАО02-16-2002 09:28 AM
SolutionYou are probably running a 10.x environment. The limitation of ARG_MAX is substantially relieved on 11.x. With that aside, there is an easy solution which is also much less resource intensive. Using 'exec' means a new process is spawned for every argument. To avoid the limitation of ARG_MAX and to avoid a new process for every argument, do this:
# find /directory/filepattern -type f -mtime +days | xargs -n 100 rm -f
Have a look at the man pages for 'xargs' for more details. Essentially this will process 100 arguments at a time until the list is exhausted.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-16-2002 09:46 AM
тАО02-16-2002 09:46 AM
Re: Simple question about eliminating files!
For safety purpose, NEVER put the -exec option (especially with rm -f) until you are sure the find actually returns the names you expect. A catastrophic result will take place if you accidently put a space in front of the * for your -name parameter !
However, you can use 'xargs' command instead of -exec, if needed.
find /dir_path -name '*pattern*' -depth -mtime days -print | xargs rm -f {}
See man pages of xargs.
HTH,
Shiju
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-16-2002 11:35 AM
тАО02-16-2002 11:35 AM
Re: Simple question about eliminating files!
This is exactly what I was looking for.