Bash - replace the space with the new line
How can I replace spaces with new lines on an input like.
/path/to/file /path/to/file2 /path/to/file3 /path/to/file4 /path/to/file5
etc...
To obtain the following.
/path/to/file
/path/to/file2
/path/to/file3
/path/to/file4
/path/to/file5
Note
I'm posting this question to help other users it's not easy to find an answer on unix se until i started to type this question I found the following
Related question
How can I find and replace with a new line?
Best Answer
Use the tr
command
echo "/path/to/file /path/to/file2 /path/to/file3 /path/to/file4 /path/to/file5"\
| tr " " "\n"
Found on http://www.unix.com/shell-programming-scripting/67831-replace-space-new-line.html