LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (http://www.linuxquestions.org/questions/linux-general-1/)
-   -   Replace blank/almost blank lines in file (http://www.linuxquestions.org/questions/linux-general-1/replace-blank-almost-blank-lines-in-file-139283/)

Wynd 01-27-2004 03:00 PM

Replace blank/almost blank lines in file
 
I have a text file with a bunch of lines that only have four spaces on them. I want to turn them into blank lines, with nothing on them. For example, I need this:
Code:

hello
   
world

to become this:
Code:

hello

world

(Highlight it with your mouse to see the difference)

Is there a way I can do this, maybe with sed?

acid_kewpie 01-27-2004 03:10 PM

cat file | sed /^\ \ \ \ $/g

homey 01-27-2004 03:35 PM

Quote:

cat file | sed /^\ \ \ \ $/g
That drives me nuts cuz I thought you had to be a bit more verbose..... :(
cat file | sed -e 's/^\ \ \ \$//g' > file2

Wynd 01-27-2004 05:49 PM

Acid: thanks, worked perfectly.


All times are GMT -5. The time now is 09:48 AM.