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



UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
remove blank lines in *.srt file :) hungbp UNIX for Dummies Questions & Answers 10 02-16-2008 08:40 AM
How to count lines - ignoring blank lines and commented lines kthatch UNIX for Dummies Questions & Answers 6 05-25-2007 01:21 AM
To remove Continous blank spaces from a file in UNIX arunkumar_mca UNIX for Dummies Questions & Answers 1 12-08-2006 01:10 AM
remove blank spaces in a string spandu Shell Programming and Scripting 2 03-02-2006 02:08 AM
delete blank lines or lines with spaces only vascobrito UNIX for Dummies Questions & Answers 3 01-13-2004 07:36 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 08-25-2005
osymad's Avatar
osymad osymad is offline
Registered User
  
 

Join Date: Sep 2001
Location: Mexico City
Posts: 10
Remove blank lines

¿How can i remove blank lines between all lines in a long text file?

Example

WrongFile.txt :
Line 1

Line 2

Line 3

CorrectFile.txt :
Line 1
Line 2
Line 3


Thanks in advance
  #2 (permalink)  
Old 08-25-2005
jingi1234 jingi1234 is offline
Registered User
  
 

Join Date: Mar 2005
Posts: 48
grep -v '^$' file_name > file_name.$$

mv file_name.$$ file_name


Hope this helps,
Jingi
  #3 (permalink)  
Old 08-26-2005
RishiPahuja's Avatar
RishiPahuja RishiPahuja is offline
Registered User
  
 

Join Date: Apr 2005
Location: Bangalore, India
Posts: 203
Thumbs up

sed '/^$/d' wrongfile > correctfile
  #4 (permalink)  
Old 08-26-2005
bakunin bakunin is offline Forum Staff  
Bughunter Extraordinaire
  
 

Join Date: May 2005
Location: In the leftmost byte of /dev/kmem
Posts: 1,628
in case the "empty" lines might contain blank characters:

grep -v '^[<spc><tab>]*$' Yourfile > correctfile

or (this one's for RishiPahuja):

sed '/^[<spc><tab>]*$/d' Yourfile > correctfile

(replace "<spc>" and "<tab>" with space and tab characters)
bakunin
  #5 (permalink)  
Old 08-27-2005
Ygor's Avatar
Ygor Ygor is offline Forum Staff  
Moderator
  
 

Join Date: Oct 2003
Location: -31.96,115.84
Posts: 1,407
awk NF WrongFile.txt > CorrectFile.txt
Sponsored Links
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 08:17 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0