【问题标题】:How can I append items to a csh list?如何将项目附加到 csh 列表?
【发布时间】:2015-02-18 13:28:49
【问题描述】:

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

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

c shell中有list.add之类的吗?

谢谢

【问题讨论】:

    标签: list csh


    【解决方案1】:

    您可以只使用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
    

    【讨论】:

    猜你喜欢
    • 2013-12-24
    • 2021-07-11
    • 2011-05-15
    • 1970-01-01
    • 1970-01-01
    • 2015-04-16
    • 2011-12-09
    • 2020-08-19
    • 1970-01-01
    相关资源
    最近更新 更多