Re:Things you (probably) didn't know about xargs
by derobert on Sunday June 26, 2011 @02:41PM
(#2698697)
On (modern, i.e. 2.6.23 and later) Linux at least, you won't hit them quickly:
$ getconf ARG_MAX
2097152
and if you do hit them, they're very easy to raise: $ ulimit -s 32768
$ getconf ARG_MAX
8388608
xargs is still useful for its other features, of course.
Re:Things you (probably) didn't know about xargs
by ptramo on Sunday June 26, 2011 @05:20PM
(#2699120)
# echo "2097152/$(echo "/my/still/quite/reasonable/path/to/a/file"|wc -c)"|bc
49932
linux-2.6 # git ls-files|wc -l 36747
Getting close! :)
And I would guesstimate (Linux, kernel >= 2.6.23) to still be a fairly small amount of the machines people interact with professionally through a command line.
And if in a script/snippet, you often want to cover a vast majority of the systems you _could_ end up with. Won't be System III, at least for me, but there has to be a RHEL5 system in a closet right? :)
Re:Things you (probably) didn't know about xargs
by LukeShu on Sunday June 26, 2011 @07:29PM
(#2699443)
That's the kernel's limit, Bash (3) has its own limit, which is significantly lower, I've hit it before. I think Bash 4 can do an arbitrary number of arguments, within the kernel's limit.
Re:Things you (probably) didn't know about xargs
by derobert on Monday June 27, 2011 @06:44PM
(#2703278)
No, bash doesn't and didn't have its own limit. On an ancient system (Debian Sarge), ARG_MAX=131072:
$ bash --version
GNU bash, version 2.05b.0(1)-release (i386-pc-linux-gnu)
Copyright (C) 2002 Free Software Foundation, Inc.
$ strace bash -c '/bin/echo `seq 1 30000`' 2>&1 | grep exec
execve("/bin/bash", ["bash", "-c", "/bin/echo `seq 1 30000`"], …) = 0
execve("/bin/echo", ["/bin/echo", "1", …) = -1 E2BIG (Argument list too long)
As you can see, the argument list too long error came back from the
execve syscall, i.e., from the kernel. (Note that I shortened the strace output to make it fit the page)
Re:Things you (probably) didn't know about xargs
by Jach on Sunday June 26, 2011 @01:41PM
(#2698508)
Of course, I meant my version as an alternative to xargs. And I think you have about 128k of space for the filenames, but yeah with large projects that can be a problem.
Thanks for the link, that's more interesting than the submission. :)
I won't go too deep on the issues this will trigger if your filenames contain special characters. We often think of spaces, but you could have some nastier stuff. If you want to sound smart at your next geeks reunion, simply read http://www.dwheeler.com/essays/fixing-unix-linux-filenames.h...