How to simply combine field separated by a slash ?
LIST=("a" "b" "c")
STRING=???
echo $STRING
a/b/c
Please someone help? Thank you.
How to simply combine field separated by a slash ?
LIST=("a" "b" "c")
STRING=???
echo $STRING
a/b/c
Please someone help? Thank you.
In BASH you can do:
list=("a" "b" "c")
printf -v str "%s/" "${list[@]}"
str="${str%/}"
Check output:
echo "$str"
a/b/c
Avoid all CAPS variables in BASH.
Alternatively using IFS
:
str=$(IFS=/; echo "${list[*]}")