【发布时间】:2018-07-16 14:55:06
【问题描述】:
在将列表转发到其他命令之前,通过某种转换(例如连接每个字符串)本质上“映射”bash 参数列表的最优雅方法是什么?想到使用xargs,但我似乎无法概念化如何做到这一点。
function do_something {
# hypothetically
for arg in "$@"; do
arg="$arg.txt"
done
command "$@"
}
do_something file1 file2 file3
结果是调用command file1.txt file2.txt file3.txt。
【问题讨论】: