- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Max arguments for rm 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
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
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-27-2011 03:45 AM
12-27-2011 03:45 AM
Max arguments for rm command
Dear Admins,
How do i determine the maximum arguments allowed in rm command? i.e number of files allowed in rm command to delete at a time.
SERVER1:/home/sit>ls -lrt|wc -l
34813
SERVER:/home/sit>rm *
sh: /usr/bin/rm: The parameter list is too long.
Regards,
V2P
- Tags:
- Arg list too long
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-27-2011 04:01 AM
12-27-2011 04:01 AM
Re: Max arguments for rm command
Hi:
[E2BIG] The number of bytes in the new program'sargument list plus environment is greater
than the system-imposed limit. This limit isat least 5120 bytes on HP-UX systems.
man 2 exec
rgs,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-27-2011 04:09 AM - edited 12-27-2011 09:36 PM
12-27-2011 04:09 AM - edited 12-27-2011 09:36 PM
Re: Max arguments for rm command
>How do I determine the maximum arguments allowed in rm command?
You don't. You have your plan A which is just "rm *".
Note: A closer estimate would be: { env; ls; } | wc -c
If you have a total length of all of the files about 2 Mb, then you switch to plan B:
find . -type -f -exec rm -f {} +
(Or you always use plan B.)
>This limit is at least 5120 bytes on HP-UX systems.
It is about 2 Mb and "-exec ... +" knows what it is, compared to dumb xargs(1).
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-27-2011 04:39 AM
12-27-2011 04:39 AM
Re: Max arguments for rm command
SERVER1:/home/sit>ls |wc -c
2022086
Bytes would be 2022086
SERVER1:/home/sit>ls |wc -l
31707
Here am able to delete the 31707 files with rm*. Is this the same calc u meant?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-27-2011 04:40 AM
12-27-2011 04:40 AM
Re: Max arguments for rm command
SERVER1:/home/sit>ls |wc -c
2022086
Bytes would be 2022086
SERVER1:/home/sit>ls |wc -l
31707
Here am able to delete the 31707 files with rm*. Is this the same calc u meant?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-27-2011 04:59 AM - edited 12-27-2011 05:48 AM
12-27-2011 04:59 AM - edited 12-27-2011 05:48 AM
Re: Max arguments for rm command
> ls | wc -c 2022086
>Bytes would be 2022086
>Here am able to delete the 31707 files with rm *. Is this the same calc you meant?
I'm saying that 2 Mb may be too large to pass as arguments.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-27-2011 05:18 AM
12-27-2011 05:18 AM
Re: Max arguments for rm command
But here am able to delete the files with rm * command. Then what parameter manages the rm max args?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-27-2011 05:39 AM
12-27-2011 05:39 AM
Re: Max arguments for rm command
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-27-2011 05:51 AM
12-27-2011 05:51 AM
Re: Max arguments for rm command
>But here am able to delete the files with rm * command. Then what parameter manages the rm max args?
Ok, I found the limit is more like 2 Mb:
$ getconf ARG_MAX
2048000
This is a fixed value.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-27-2011 04:49 PM - edited 12-27-2011 06:01 PM
12-27-2011 04:49 PM - edited 12-27-2011 06:01 PM
Re: Max arguments for rm command
The correct answers are:
- There is no limit to the number of files that can be deleted, but
- there is a limit to the number of characters on the command line
So for the specific example: rm *
The star * is a special character for the shell and for default environments, it will effectively rewrite the command line with rm plus the names of all the files in the current directory. If every file is exactly two letters (as in aa, ab, ac, ad...Aa, Ab, Ac...11, 12, 13,...) then about 666,000 files can be removed with the rm command (2 characters plus 1 space).
So it has nothing to do with the number of files, it has to do with the length of the resultant command line. It is not a good idea to think of managing massive numbers of files with simple file matching characters like "*". The first consideration is what can you do to stop the madness of having thousands of files in one directory. HP-UX has no problems with thousands, even millions of files in one directory. But the fact that it can be done does not make it a good idea. Most of the massive directory problems I have seen have been due to bad designs trying to create a database with files rather than using a real database.
Now if you are forced to deal with a bad design that will not be fixed, the next best is to use command lines that will work and avoid those that fail or take enormous amounts of time (and disk I/O). Assuming your current directory has 1 million files, the first commands to avoid are simple ls and ll commands. The result will scroll off the top of your screen, onto the floor and down the stairs...
Instead, you limit the listing to what you are really looking for. If you are looking for files that start with the characters abc and end with 123, then limit the match: ls abc*123 . If you need to remove all the files in a directory (with no subdirectories), then use rm -r mydirname and *not* rm mydirname/*
If the directory has subdirectories, you'll have to be more creative by breaking the filenames into manageable groups.
Bill Hassell, sysadmin