Unix/Linux Go Back    


Shell Programming and Scripting Unix shell scripting - KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and shell scripts and shell scripting languages here.

Remove all blank lines in shell or awk.

Shell Programming and Scripting


Tags
awk, awk trim, trim, trim awk

Closed Linux or Unix Question    
 
Thread Tools Search this Thread Display Modes
    #1  
Old Unix and Linux 10-13-2008
tushar_tus tushar_tus is offline
Registered User
 
Join Date: Aug 2008
Last Activity: 27 November 2009, 2:10 AM EST
Posts: 29
Thanks: 0
Thanked 0 Times in 0 Posts
Remove all blank lines in shell or awk.

Hi there,


I want to trim space between lines in unix.
I have a file named abc.txt with 2,00,000 lines.But useful are only a few. Please tell me how to delete the blank lines.Linux
Sponsored Links
    #2  
Old Unix and Linux 10-13-2008
cfajohnson's Unix or Linux Image
cfajohnson cfajohnson is offline Forum Advisor  
Shell programmer, author
 
Join Date: Mar 2007
Last Activity: 27 July 2015, 12:41 PM EDT
Location: Toronto, Canada
Posts: 2,896
Thanks: 0
Thanked 131 Times in 116 Posts

Take your pick:


Code:
tr -s '\n' < abc.txt

grep -v "^$" abc.txt

sed '/^$/d' abc.txt

sed '/./!d' abc.txt

awk '/./' abc.txt

Sponsored Links
Closed Linux or Unix Question

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Linux More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
How to remove blank lines mayursingru Shell Programming and Scripting 13 05-26-2011 07:35 AM
Delete blank lines, if blank lines are more than one using shell anil8103 Shell Programming and Scripting 5 05-10-2011 07:21 PM
remove blank lines and merge lines in shell dvah Shell Programming and Scripting 11 03-09-2011 08:45 AM
Remove blank lines KidCactus Shell Programming and Scripting 9 10-05-2010 11:37 AM
Shell script: Remove blank lines gholdbhurg Shell Programming and Scripting 3 02-25-2009 01:33 PM



All times are GMT -4. The time now is 02:07 AM.