Today I have tried to remove 3500 files at once using the argument expantion of bash: "rm *.txt" There was an error: *bash: /bin/mv: Argument list too long *Here is the explanation and the workaround:
> bash: /bin/mv: Argument list too long > > The UNIX operating system tradionally has a fixed limit for the amount > of memory that can be used for a program environment and argument list > combined. You can use getconf to return that limit. On my Linux system > (2.2.12) that amount is 128k. On my HP-UX system (11.0) that amount is > 2M. It can vary per operating system. POSIX only requires 20k which > was the traditional value used for probably 20 years. Newer operating > systems releases usually increase that somewhat. > > getconf ARG_MAX > 131072 > > Note that your message came from "bash" your shell command line > interpreter. Its job is to expand command line wildcard characters > that match filenames. It expands them before any program can see > them. This is therefore common to all programs on most UNIX-like > operating systems. It cannot exceed the OS limit of ARG_MAX and if it > tries to do so the error "Argument list too long" is returned to the > shell and the shell returns it to your. > > This is not a bug in 'mv' or other utilitities nor is it a bug in 'bash' > or any other shell. It is an architecture limitation of UNIX-like > operating systems. However, it is one that is easily worked around > using the supplied utilities. Please review the documentation on 'find' > and 'xargs' for one possible combination of programs that work well. > > You might think about increasing the value of ARG_MAX but I advise > against it. Any limit, even if large, is still a limit. As long as it > exists then it should be worked around for robust script operation. On > the command line most of us ignore it unless we exceed it at which time > we fall back to more robust methods. > > Here is an example using chmod where exceeding ARG_MAX argument length > is avoided. > > find htdocs -name '*.html' -print0 | xargs -0 chmod a+r -------------------- BYU Unix Users Group http://uug.byu.edu/ The opinions expressed in this message are the responsibility of their author. They are not endorsed by BYU, the BYU CS Department or BYU-UUG. ___________________________________________________________________ List Info: http://uug.byu.edu/cgi-bin/mailman/listinfo/uug-list