是否有可能增加的ksh变量接受的最大字符数? [英] Is it possible to increase the maximum number of characters that ksh variable accepts?
问题描述
这是一个跟进问题。
<一个href=\"http://stackoverflow.com/questions/14371326/what-is-the-maximum-number-of-characters-that-the-ksh-variable-accepts\">What就是KSH变量接受的最大字符数?
我检查了我的环境,它仅允许
的#include&LT; SYS / limits.h中&GT;
$ CPP&LT;&LT;这里|尾-1
&GT; #包括LT&;&limits.h中GT;
&GT; ARG_MAX
&GT;这里
1048576
有没有增加这个办法?或任何替代品
而读线;
做
#parse逻辑
完成&LT; $文件名
要处理很长的线?从记录基于我解析它在2M字符行不会停止。
环境细节:
AIX $ KSH版本M-11/16 / 88F
您可以编写一个Linux 3.7.x内核,并编辑其包含/ uapi / Linux的/ limits.h中
文件来增加 ARG_MAX
参数(为两个部分功率较大,如2097152)。但是,你如果你想增加它更应该相当有很多的RAM(例如8GB的)。
实际的限制是有关的execve( 2)。那个人页面上有一个段落。
但你很可能避免巨大的shell变量(在Unix环境)。你有没有考虑使用一些其他的工具( AWK
,蟒蛇
, perl的
....)来读取你的文件吗?其可变环境是不发送至分叉方案外壳的环境中,所以它们可以有很长的值的变量。也许 KSH
有一些内置(取消导出
),以避免出口某些变量到Unix环境。
This is a follow up question to
What is the maximum number of characters that the ksh variable accepts?
I checked my environment and it's allowing only
#include <sys/limits.h>
$ cpp << HERE | tail -1
> #include <limits.h>
> ARG_MAX
> HERE
1048576
Is there a way to increase this? Or any alternatives for
while read line;
do
#parse logic
done < $filename
To handle really long lines? Based from the records I'm parsing it will not stop at 2M character lines.
Environment Details :
AIX $ KSH Version M-11/16/88f
You could compile a Linux 3.7.x kernel, and edit its include/uapi/linux/limits.h
file to increase the ARG_MAX
argument (to some bigger power of two, e.g. 2097152). But you should rather have a lot of RAM (e.g. 8GBytes) if you want to increase it more.
The actual limit is related to execve(2). That man page has a paragraph on it.
But you could probably avoid having huge shell variables (in the Unix environment). Did you consider using some other tool (awk
, python
, perl
....) to read your file? Their variable environment is not the shell environment transmitted to forked programs, so they can have variables with very long values. Maybe ksh
has some builtin (unexport
) to avoid exporting some variable into the Unix environment.
这篇关于是否有可能增加的ksh变量接受的最大字符数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!