[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Help-bash] Fastest way to join an array into a string
From: |
Peng Yu |
Subject: |
[Help-bash] Fastest way to join an array into a string |
Date: |
Mon, 26 Aug 2019 13:47:36 -0500 |
Hi,
I'd like to do something similar to str.join() in python.
Suppose the array is in $@, I currently use the following code to
print the joined result ($separator contains the separator to join the
string). Is it the fastest way to do so in bash? Thanks.
echo -n "$1"
shift
if (($#)); then
declare x
printf "${separator//%/%%}%s" "$@"
fi
--
Regards,
Peng
- [Help-bash] Fastest way to join an array into a string,
Peng Yu <=