LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices

Reply
 
Search this Thread
Old 01-27-2004, 02:00 PM   #1
Wynd
Member
 
Registered: Jul 2001
Distribution: Slackware 12
Posts: 511

Rep: Reputation: 32
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?
 
Old 01-27-2004, 02:10 PM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,396

Rep: Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963
cat file | sed /^\ \ \ \ $/g

Last edited by acid_kewpie; 01-27-2004 at 02:12 PM.
 
Old 01-27-2004, 02:35 PM   #3
homey
Senior Member
 
Registered: Oct 2003
Posts: 3,057

Rep: Reputation: 56
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
 
Old 01-27-2004, 04:49 PM   #4
Wynd
Member
 
Registered: Jul 2001
Distribution: Slackware 12
Posts: 511

Original Poster
Rep: Reputation: 32
Acid: thanks, worked perfectly.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
output number of blank lines tjgadu Linux - Newbie 7 06-09-2005 04:01 PM
screen suspend/blank conf file? chunlee Linux - Newbie 1 01-07-2005 10:38 AM
vim: mark end-of-line? trim blank lines? prell Linux - Software 3 09-20-2004 11:04 PM
How do i remove blank lines from a file? kakho Programming 1 04-15-2004 03:57 AM
Screen goes blank(random) to vertical lines bruce1271 Linux - General 2 11-15-2003 11:02 AM


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

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration