BASH printf array with field separator and newline on last entry -
How can I print an array with a field separator between each value and a new line in BASH.
The closest I can get with a single printf is Is there a way to do it on one line or me thanks, gerrant Yes, for this you need two commands. Alternatively, if you are sequential printf '% s |' "$ {AR1 [@]}" where | Field separator. The problem with this is that there is no line break at the end \ NI try to enter any combination or any line breaks on every entry or none!
printf '% s' | "$ {Arr1 [@]}"; Printf "\ n"
Print '% s' | "$ {Array {@}}"; Resonance is completely conventional.
| , you can temporarily modify
IFS , select the separator as your first letter, and
"$ {array [*]}" :
Use IFS = "| $ IFS"; Printf '% s \ n' "$ {array [*]}"; IFS = "$ {IFS: 1}"
Comments
Post a Comment