SUMMARY: Argument limits on mv, awk, ls

From: Strong, Rick \(Maxim\) <"Strong,>
Date: Thu, 11 Jan 2001 12:42:19 -0600

All,

Several good suggestions, which I will be exploring. Thanks!

1. Several pointed me to xargs:
        a. "That's good old ARG_MAX. You can work around this using xargs,
as in: 'find . -name foo\* | xargs rm'. See the man page on xargs for
details."
        b. "One limit you might hit is ARG_MAX. From the exec(2) manpage:
The exec functions set errno to the specified values for the following
con­ditions:[E2BIG] The number of bytes used by the new process image's
argument list and environment list is greater than ARG_MAX bytes.
/usr/include/sys/syslimits.h #defines ARG_MAX to 38912 bytes on my
system.The problem occurs when the shell expands a pattern in a large
directory? In this case one can often use find and xargs similar to: 'find .
-name 'pattern' -print |xargs command'
        c. "The xargs program is typically used to solve this although
there are other solutions with awk such as reading the arguments from a
regular file or "here" file."
        d. "use xargs for mv ls; use perl in place of awk"
        e. "check out xargs."
2. One mentioned ulimit:
"If you are doing something like: 'mv * xx' then you are probably exceeding
the stack size. Use 'ulimit -H -a' to see what the hard limits are. Also
need to check 'ulimit -S -a', as they may be lower. Use 'ulimit -s nnnnn' to
change the stack limits."

3. A couple of 'for' loop solutions:
        a. "I came across a limit on "rm"... went with: 'for i in `ls` do rm
$i done'
        b. "The solution was to do something like this: 'ls | grep
somepattern > /tmp/junk.lis' and then parse thru junk.lis with a for loop
(in Bourne shell)."

Rick Strong
EDS MCI Production Support
Received on Thu Jan 11 2001 - 18:44:25 NZDT

This archive was generated by hypermail 2.4.0 : Wed Nov 08 2023 - 11:53:41 NZDT