list - 如何将项目附加到 csh 列表?

标签 list csh

我想创建一个包含适用于某些字符串的列表 csh 中的条件。

如何在不预先确定的情况下以动态方式添加到列表或数组 列表或数组的大小?

c shell 中是否有 list.add 或类似的东西?

谢谢

最佳答案

您可以只使用set my_list = ( $my_list more ) 的形式。例如:

# Create original list
% set my_list = ( hello world )
% echo $my_list
hello world

# Append to the list
% set my_list = ( $my_list hey there )
% echo $my_list
hello world hey there

# Loop over the list to verify it does what we expect it to do
% foreach item ($my_list)
foreach? echo "-> $item"
foreach? end
-> hello
-> world
-> hey
-> there

关于list - 如何将项目附加到 csh 列表?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28584817/

相关文章:

list - 在同一行中打印列表的元素

r - 如何拆分 data.frame 列表并将函数应用于一列?

python - 使用带有用户输入的循环通过 python 下载图像列表

linux - csh 内联数学

linux - 使用 grep 选择与列表中的任何单词匹配的行

list - 比计算单位列表长度更好的方法

c# - 包含两项并且可以通过另一项返回一项的数据结构列表

linux - 使用 foreach 循环时不会出现列的最大值

linux - 使用 tcsh 中的 if 条件进行模式匹配

linux - Shell脚本,失败则停止运行