split string by new line code example
Example 1: split by new line java
String lines[] = string.split("\\r?\\n");
Example 2: split string into lines
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'