Shell - syntax to remove blank lines

Hi,

Im running Solaris 10 and I have the this file:

089724051000029770 551891074630

089724051000029776 551891074636

089724051000029857 551891074717

.
.

I want it not to have these blank lines anymore, it will look like something like this:

089724051000029770 551891074630
089724051000029776 551891074636
089724051000029857 551891074717
.
.

What would be the fastest way to do it?

Tks,
Joao
joaotellesAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
Dave GouldConnect With a Mentor Onsite SupportCommented:
They are not blank lines. Just very long lines. You need to remove the trailing spaces.

try
 sed 's/\W*$//' your_file
0
 
farzanjCommented:
Try
sed /^$/d filename

Open in new window



For modifying the file (inline modification) you can do
sed -i '/^$/d' filename

Open in new window

0
 
arnoldCommented:
adding to farzanj to address spaces on line
sed -i '/^[ ]*$/d' filename
or to remove any empty line with white space
sed -i '/^\W+$/d' filename
0
Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

 
joaotellesAuthor Commented:
Im running the option without the i because it failed..

> sed -i '/^$/d' minus_first.lst
sed: illegal option -- i
> sed -i '/^[ ]*$/d' minus_first.lst
sed: illegal option -- i

This is what Im running:
> sed /^$/d minus_first.lst > minus_1.txt
0
 
arnoldCommented:
You're on Solaris, the -i option I think is a GNU sed.
If your example does not work, try

awk ' (length ($0) >1 { print } ' filename

No check for empty spaces exclusion.
0
 
manny17Commented:
sed -n '/^$/d' file_name > file_name1
mv file_name1 file_name
0
 
MazdajaiCommented:
perl -i -ne 'print if /\S/' minus_first.lst

Open in new window

0
 
ozoCommented:
grep . file_name > file_name1
or
grep '[[:graph:]]' file_name > file_name1
0
 
joaotellesAuthor Commented:
Hi,

None of the solutions worked :(((

I have attached a sample fo the file.. maybe it helps.. Im running Solaris 10.
sample
sample
0
 
joaotellesAuthor Commented:
tks.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.