The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #1 (permalink)  
Old 10-08-2007
sovixi sovixi is offline
Registered User
  
 

Join Date: Oct 2007
Posts: 1
sed - adding new line

I want to use sed to look for spaces in text and when find one move the next word to the next line.

I used:

sed 's/ /\n/g' out > new

However when there is more than one space between two words it adds more lines between them. And I just want the words to be one under another. How can I change that?

Thanks

I find out how to do this:

sed '/^$/d'

However when I'm using emacs and put this two commands in one line they don't want to work:

#! /bin/bash
sed 's/ /\n/g' | sed '/^$/d' out > new

What I'm doing wrong???

Last edited by sovixi; 10-08-2007 at 08:56 PM..