put each word in new line - sed or tr

Hello !

I have a result of ls command in a file:

file1 file2 file3.out file4.pdf file5

they all are separated by space.

I need to put them on a separate line
example:
file1
file2
file3.out
file4.pdf
fil35

i tried
sed 's/ /\n/g' inputfile > outputfile
but did not help

also tried tr command but no result.

Please help.
thank you.

tr should work. use this

tr ' ' '\n' < file

To add newline using SED use this

sed -f script file

script
################
s/ /\
/g
################

thank you.
that was very helpful.

:slight_smile: