【发布时间】:2012-12-07 22:50:29
【问题描述】:
当我需要使用不同的参数多次运行命令时,我使用了这种方法(没有完全理解它):
touch {a,b,c}
相当于:
touch a
touch b
touch c
我认为同样可以通过以下循环实现:
for file in {a,b,c}; do touch $file; done
但是我偶然发现了一个不起作用的情况:
pear channel-discover {"pear.phpunit.de","pear.symfony-project.com"}
我有几个问题:
- 第一个示例中发生的事情的名称是什么?到底发生了什么?
- 将这种方法用于简单的事情是否比 for-in 循环更好?
- 为什么 pear 命令不能这样工作?命令脚本应该实现一些技术来处理这些参数,还是由 shell 负责?
【问题讨论】:
标签: bash shell command-line command-line-arguments brace-expansion