在 bash 中,如何将 N 个参数作为空格分隔的字符串连接在一起 [英] In bash, how do I join N parameters together as a space separated string
本文介绍了在 bash 中,如何将 N 个参数作为空格分隔的字符串连接在一起的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试编写一个函数,它接受 n 个参数并将它们连接成一个字符串.
I'm trying to write a function that takes n parameters and joins them into a string.
在 Perl 中是
my $string = join(' ', @ARGV);
但在 bash 中我不知道该怎么做
but in bash I don't know how to do it
function()
{
??
}
推荐答案
检查 bash
手册页中特殊参数"下的*"条目.
Check the bash
man page for the entry for '*' under Special Parameters.
join () {
echo "$*"
}
这篇关于在 bash 中,如何将 N 个参数作为空格分隔的字符串连接在一起的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文