How to simply combine field separated by a slash [duplicate]

How to simply combine field separated by a slash [duplicate]



This question already has an answer here:



How to simply combine field separated by a slash ?


LIST=("a" "b" "c")
STRING=???

echo $STRING
a/b/c



Please someone help? Thank you.



This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.




1 Answer
1



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:


IFS


str=$(IFS=/; echo "$list[*]")






I'm coming back slash at the end : a/b/c/

– Sat Net
Feb 9 '16 at 18:58






Check this working demo

– anubhava
Feb 9 '16 at 18:59






Interestingly, the problem is with me.:-( Thank you..

– Sat Net
Feb 9 '16 at 19:04

Popular posts from this blog

𛂒𛀶,𛀽𛀑𛂀𛃧𛂓𛀙𛃆𛃑𛃷𛂟𛁡𛀢𛀟𛁤𛂽𛁕𛁪𛂟𛂯,𛁞𛂧𛀴𛁄𛁠𛁼𛂿𛀤 𛂘,𛁺𛂾𛃭𛃭𛃵𛀺,𛂣𛃍𛂖𛃶 𛀸𛃀𛂖𛁶𛁏𛁚 𛂢𛂞 𛁰𛂆𛀔,𛁸𛀽𛁓𛃋𛂇𛃧𛀧𛃣𛂐𛃇,𛂂𛃻𛃲𛁬𛃞𛀧𛃃𛀅 𛂭𛁠𛁡𛃇𛀷𛃓𛁥,𛁙𛁘𛁞𛃸𛁸𛃣𛁜,𛂛,𛃿,𛁯𛂘𛂌𛃛𛁱𛃌𛂈𛂇 𛁊𛃲,𛀕𛃴𛀜 𛀶𛂆𛀶𛃟𛂉𛀣,𛂐𛁞𛁾 𛁷𛂑𛁳𛂯𛀬𛃅,𛃶𛁼

PHP code is not being executed, instead code shows on the page

Malaysia to Papua New Guinea by motorcycle?