什么是该KSH变量接受的最大字符数? [英] What is the maximum number of characters that the ksh variable accepts?
问题描述
我试图加载和分析一个真正的大文本文件。虽然装载是没有问题的,但存在具有在一行2908778字符特定行。
I am trying to load and parse a really large text file. Although the loading is not a problem, but there are particular lines that have 2908778 characters on a single line.
这是我的脚本导致错误。
This is causing an error in my script.
在下面的脚本,我删除了所有的逻辑和刚刚直读线。
我也删除所有有效线路和刚刚离开一个文本文件中的很长的线。在运行时我得到以下错误:
On the script below, I removed all logic and just got straight to read line. I also removed all valid lines and just left the really long line in one text file. When running I get the below error :
$ dowhiledebug.sh dump.txt
dowhiledebug.sh[6]: no space
Script Ended dump.txt
实际的脚本:
#!/bin/sh
filename=$1
count=1
if [ -f ${filename} ]; then
echo "after then"
while read line;
do
echo "$count"
count=$((count+1))
done < $filename
else
echo "Could not open file $filename"
fi
echo "Script Ended $filename"
更新(2013年1月17日)
Updated (2013-01-17)
跟进的问题:<一href=\"http://stackoverflow.com/questions/14387344/is-it-possible-to-increase-the-maximum-number-of-characters-that-ksh-variable-ac\">Is有可能以增加的ksh可变接受?的最大字符数
推荐答案
任何外壳的限制是C命令行最大的极限。这里有一个小程序,把信息从 /usr/include/limits.h
的你:
The limit for any shell is the limit of the C command line maximum. Here's a little program that pulls the information out of /usr/include/limits.h
for you:
cpp <<HERE | tail -1
#include <limits.h>
ARG_MAX
HERE
煤矿给我(256 * 1024)或262144字符。
Mine gives me (256 * 1024) or 262144 characters.
如果未安装C编译器不工作,但它可能是一个类似的限制。
Doesn't work if the C compiler isn't installed, but it's probably a similar limit.
这篇关于什么是该KSH变量接受的最大字符数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!