在bash中,如何将N个参数连接在一起作为空格分隔的字符串 [英] In bash, how do I join N parameters together as a space separated string

查看:23
本文介绍了在bash中,如何将N个参数连接在一起作为空格分隔的字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

I'm trying to write a function that takes n parameters and joins them into a string.

In Perl it would be

my $string = join(' ', @ARGV);

but in bash I don't know how to do it

function()
{
    ??
}

解决方案

Check the bash man page for the entry for '*' under Special Parameters.

join () {
    echo "$*"
}

这篇关于在bash中,如何将N个参数连接在一起作为空格分隔的字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆