Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/linux/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Linux UNIX中变量的长度_Linux_Unix - Fatal编程技术网

Linux UNIX中变量的长度

Linux UNIX中变量的长度,linux,unix,Linux,Unix,如果有人能告诉我UNIX变量的总长度,我将不胜感激。 我有一个名为filelist的变量,我想这样保存内容: filelist=path/name path/name path/name path/name path/name path/name path/name 路径/名称路径/名称路径/名称路径/名称路径/名称路径/名称路径/名称路径/名称 路径/名称路径/名称路径/名称路径/名称路径/名称路径/名称路径/名称路径/名称 路径/名称路径/名称路径/名称路径/名称路径/名称路径/名称路径/名

如果有人能告诉我UNIX变量的总长度,我将不胜感激。 我有一个名为filelist的变量,我想这样保存内容:

filelist=path/name path/name path/name path/name path/name path/name path/name 路径/名称路径/名称路径/名称路径/名称路径/名称路径/名称路径/名称路径/名称 路径/名称路径/名称路径/名称路径/名称路径/名称路径/名称路径/名称路径/名称 路径/名称路径/名称路径/名称路径/名称路径/名称路径/名称路径/名称路径/名称 路径/名称路径/名称路径/名称路径/名称路径/名称路径/名称路径/名称路径/名称 路径/名称路径/名称路径/名称路径/名称路径/名称路径/名称路径/名称路径/名称 路径/名称路径/名称路径/名称路径/名称路径/名称路径/名称路径/名称路径/名称 路径/名称路径/名称路径/名称路径/名称路径/名称路径/名称路径/名称路径/名称 路径/名称路径/名称路径/名称路径/名称路径/名称路径/名称路径/名称路径/名称 路径/名称路径/名称路径/名称路径/名称路径/名称路径/名称路径/名称路径/名称 路径/名称路径/名称路径/名称路径/名称路径/名称路径/名称路径/名称路径/名称 路径/名称路径/名称路径/名称路径/名称路径/名称路径/名称路径/名称路径/名称 路径/名称路径/名称路径/名称路径/名称路径/名称路径/名称 路径/名称…无限


有两个限制。第一个在壳里面。我猜
bash
并没有对其变量进行太多限制,真正的限制是可用资源(如果
malloc
失败)

更重要的一个(与
scp$文件列表相关)id@remotohost:path
case)是当您使用该变量时,例如执行某个程序。然后调用,它可能会失败,因为整个程序参数占用了太多内存。阅读手册页的参数大小限制和环境部分:

参数和环境的大小限制

大多数UNIX实现对
命令行参数(argv)和环境(envp)字符串可能
被传递给一个新的程序。POSIX.1允许实现
使用ARG_MAX常量(在
或在运行时使用调用
sysconf(_SC_ARG_MAX))。
实际上,
execve
限制非常重要(例如默认为128KB)。我经常在编辑一些内核头文件后编译自己的内核,以提高该限制(例如,1字节)

请注意,在
bash
中导出的
export
-ed变量会进入受上述限制的环境(未来分叉进程)


顺便说一句,您可以通过其他方式传输文件(
rsync
git
等…)。

哪个shell?我想BASH?你最好用一个文件来存储它。无论如何,你必须管理数据。我真的不知道,但我相信有更好的方法可以做到这一点好的…我需要这个,因为我想以后做scp$文件列表id@remotohost:路径
   Most UNIX implementations impose some limit on the total size of the
   command-line argument (argv) and environment (envp) strings that may
   be passed to a new program.  POSIX.1 allows an implementation to
   advertise this limit using the ARG_MAX constant (either defined in
   <limits.h> or available at run time using the call
   sysconf(_SC_ARG_MAX)).