Answers for "split string in bash in array"

1

split string and create array bash

my_array=($(echo $string | tr "," "\n"))
Posted by: Guest on April-17-2020
1

How to split a string in bash

string="you got a friend in me"
IFS=' ' read -ra split <<< "$string"
echo "${split[*]}"
# Output: you got a friend in me
echo "${split[3]}"
# Output: friend
Posted by: Guest on March-14-2022

Code answers related to "split string in bash in array"

Code answers related to "Shell/Bash"

Browse Popular Code Answers by Language