↧
Answer by nicolas for Print array elements on separate lines in Bash?
In zsh one can use the built-in command print -l $path
View ArticleAnswer by Delyan Lazarov for Print array elements on separate lines in Bash?
You could use a Bash C Style For Loop to do what you want.my_array=(one two three)for ((i=0; i < ${#my_array[@]}; i++ )); do echo "${my_array[$i]}"; doneonetwothree
View ArticleAnswer by Mario Nigrovic for Print array elements on separate lines in Bash?
I've discovered that you can use eval to avoid using a subshell. Thus:IFS=$'\n' eval 'echo "${my_array[*]}"'
View ArticleAnswer by 0x00 for Print array elements on separate lines in Bash?
Another useful variant is pipe to tr:echo "${my_array[@]}" | tr '''\n'This looks simple and compact
View ArticleAnswer by Zombo for Print array elements on separate lines in Bash?
Using for:for each in "${alpha[@]}"do echo "$each"doneUsing history; note this will fail if your values contain !:history -p "${alpha[@]}"Using basename; note this will fail if your values contain...
View ArticleAnswer by wuxmedia for Print array elements on separate lines in Bash?
I tried the answers here in a giant for...if loop, but didn't get any joy - so I did it like this, maybe messy but did the job: # EXP_LIST2 is iterated # imagine a for loop EXP_LIST="List item"...
View ArticleAnswer by perreal for Print array elements on separate lines in Bash?
Just quote the argument to echo:(IFS=$'\n'; echo "${my_array[*]}")the sub shell helps restoring the IFS after use
View ArticleAnswer by Gilles Quénot for Print array elements on separate lines in Bash?
Try doing this :$ printf '%s\n'"${my_array[@]}"The difference between $@ and $*:Unquoted, the results are unspecified. In Bash, both expand to separate argsand then wordsplit and globbed.Quoted, "$@"...
View ArticlePrint array elements on separate lines in Bash?
How do I print the array element of a Bash array on separate lines? This one works, but surely there is a better way:$ my_array=(one two three)$ for i in ${my_array[@]}; do echo $i;...
View Article
More Pages to Explore .....