bash split text code example
Example 1: split string and create array bash
my_array=($(echo $string | tr "," "\n"))
Example 2: split bash string
IN="[email protected];[email protected]"
arrIN=(${IN//;/ })
Example 3: separate words in lines bash
Just use tr command for separating words output into separate lines:
tr -s '[[:punct:][:space:]]' '\n'
Example for
cat file.txt | tr -s '[[:punct:][:space:]]' '\n'