Solved

How can I remove blank lines from the file ?

Posted on 2000-03-23
8
220 Views
Last Modified: 2010-04-21
Hi experts,

I have so many blank lines in the file.How can I remove those lines ?

I am using SunOS.

Thanks in Advance!
0
Comment
Question by:sganta
  • 3
  • 2
  • 2
  • +1
8 Comments
 
LVL 20

Expert Comment

by:tfewster
ID: 2648684
grep -v ^$ your_file > new_file
0
 
LVL 4

Expert Comment

by:urim
ID: 2648685
awk 'NF > 0 {print $0}'

this will return the rows that have something in it.
0
 
LVL 20

Expert Comment

by:tfewster
ID: 2648703
urim's answer is better, as mine would print a line that had spaces etc. on it

Nice one, urim
0
 

Accepted Solution

by:
thacsi earned 50 total points
ID: 2648785
egrep -v "^ *$" will remove all blank lines including those with spaces.
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 20

Expert Comment

by:tfewster
ID: 2648821
thacsi, if that's what is wanted, then urim was the first to give a correct solution. Please change your answer to a comment,  and allow sganta to decide which is the most useful.
0
 
LVL 4

Author Comment

by:sganta
ID: 2652026
Hi Experts,

Thank you for all your help. Urim was the first to answer the question. So, I am giving points to him. Inany way
I will also give points to "thacsi" and "tfewster" for your help.

Lots of thanks
sganta
0
 
LVL 4

Author Comment

by:sganta
ID: 2652029
I am sorry, by mistake I gave to thacsi, In any way I want to give points
to all of you. So I will give the points to urim and tfewster.
0
 

Expert Comment

by:thacsi
ID: 2661028
Sqanta:

egrep -v "^$|^ *$|^\^I$" file
will remove null blank lines in parse 1, 1 to n spaces in parse 2 and tabs in parse 3. I tried it, it will work.

0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Suggested Solutions

My previous tech tip, Installing the Solaris OS From the Flash Archive On a Tape (http://www.experts-exchange.com/articles/OS/Unix/Solaris/Installing-the-Solaris-OS-From-the-Flash-Archive-on-a-Tape.html), discussed installing the Solaris Operating S…
Using libpcap/Jpcap to capture and send packets on Solaris version (10/11) Library used: 1.      Libpcap (http://www.tcpdump.org) Version 1.2 2.      Jpcap(http://netresearch.ics.uci.edu/kfujii/Jpcap/doc/index.html) Version 0.6 Prerequisite: 1.      GCC …
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
In a previous video, we went over how to export a DynamoDB table into Amazon S3.  In this video, we show how to load the export from S3 into a DynamoDB table.

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now