Skip to main content

Concatenating all arguments of a function/removing all spaces from a variable [Resolved]

What's a good way to concatenate all arguments of a function?

What I got at the moment is iterating over them and appending them consecutively:

func(){
concat=
for arg in "$@"
do
    concat=$concat$arg
done
echo $concat
}

I'd like to potentially do something like:

another_func() {
echo $(remove_spaces $@)
}

Question Credit: y_wc
Question Reference
Asked March 23, 2019
Posted Under: Unix Linux
9 views
3 Answers

Your Answer