stringbasharguments

In bash, how do I join N parameters together as a space separated string


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()
{
    ??
}

Solution

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

    join () {
        echo "$*"
    }