加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

什么是好的等价于bash中的Perl列表?

发布时间:2020-12-15 20:04:26 所属栏目:安全 来源:网络整理
导读:在perl中,只需执行以下操作来存储和遍历名称列表 my @fruit = (apple,orange,kiwi);foreach (@fruit) { print $_;} 什么是等价的在bash? bash(不像POSIX sh)支持数组: fruits=(apple orange kiwi "dried mango")for fruit in "${fruits[@]}"; do echo "${
在perl中,只需执行以下操作来存储和遍历名称列表
my @fruit = (apple,orange,kiwi);
foreach (@fruit) {
        print $_;
}

什么是等价的在bash?

bash(不像POSIX sh)支持数组:
fruits=(apple orange kiwi "dried mango")
for fruit in "${fruits[@]}"; do
  echo "${fruit}"
done

这具有数组元素可以包含空格或$ IFS的其他成员的优点;只要它们作为单独的元件正确插入,它们就以相同的方式读出。

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读