Link to home
Start Free TrialLog in
Avatar of sganta
sganta

asked on

How can I remove blank lines from the file ?

Hi experts,

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

I am using SunOS.

Thanks in Advance!
Avatar of tfewster
tfewster
Flag of United Kingdom of Great Britain and Northern Ireland image

grep -v ^$ your_file > new_file
Avatar of urim
urim

awk 'NF > 0 {print $0}'

this will return the rows that have something in it.
urim's answer is better, as mine would print a line that had spaces etc. on it

Nice one, urim
ASKER CERTIFIED SOLUTION
Avatar of thacsi
thacsi

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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.
Avatar of sganta

ASKER

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
Avatar of sganta

ASKER

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.
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.