Is it possible to increase the maximum number of characters that the ksh variable accepts?

This is the next question to

What is the maximum number of characters the ksh variable accepts?

I checked my environment and allowed only

#include <sys/limits.h> $ cpp << HERE | tail -1 > #include <limits.h> > ARG_MAX > HERE 1048576 

Is there any way to increase this? Or any alternatives for

  while read line; do #parse logic done < $filename 

To handle really long lines? Based on the entries I am parsing, it does not stop at 2M character strings.

Environment Details:

  AIX $ KSH Version M-11/16/88f 
+2
linux unix bash ksh
Jan 17 '13 at 20:13
source share
1 answer

You can compile the Linux 3.7.x kernel and edit its include/uapi/linux/limits.h file to increase the argument ARG_MAX (to some more powerful two, for example, 2097152). But you must have more RAM (for example, 8 GB) if you want to increase it more.

The actual limit is related to execve (2) . This man page contains a paragraph on it.

But you could probably avoid the huge shell variables (on a Unix environment). Do you consider using any other tool ( awk , python , perl ....) to read your file? Their environment variable is not a shell environment passed into branched programs, so they can have variables with very long values. Perhaps ksh has a built-in ( unexport ) to avoid exporting some variable to the Unix environment.

+2
Jan 17 '13 at 20:22
source share



All Articles