convert space into new line using sed command

In this sed command trick we will learn how to convert space into new line.For more understanding we will take an example. In file called test we have written colour names with spaces.Now we will convert the space into new line.

Syntax:

sed 's/s/n/g' file_name

example is given below

linux@tuxworld:/tmp$ cat test 
red blue green yellow orange white black violet maroon brown color
linux@tuxworld:/tmp$ 
linux@tuxworld:/tmp$ sed 's/s/n/g' test
red
blue
green
yellow
orange
white
black
violet
maroon
brown
color
linux@tuxworld:/tmp$ 

Read Some More Articles

One Comment

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.