Linux Ask!

Linux Ask! is a Q & A web site specific for Linux related questions. Questions are collected, answered and audited by experienced Linux users.

Convert spaces into new lines using sed

Answer:

If you have a text file like:

1 2 3 4 5

How to convert the spaces into new lines?

Use sed!

# sed 's/ /\n/g' text.txt
  1. How to convert tab into spaces?
  2. How to convert spaces into tabs?
  3. How to expand tab into spaces in vi / vim
  4. Convert Windows text file to UNIX format without dos2unix
  5. Remove specified lines from a file using sed

Leave a Reply

(required)

(required)

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>