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

时间:2015-02-18 13:28:50

标签: list csh

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

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

c shell中是否有list.add或其他类似内容?

由于

1 个答案:

答案 0 :(得分:3)

您可以使用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
相关问题