Delete empty lines from a file

Delete empty lines from a file

am 06.11.2007 12:11:43 von shulamitm

Hello all,

I need to delete empty lines from a file (with spaces only - not null
records). The following command works only for null rows, but not in
case of spaces: sed '/^$/d' filename

thanks in advance!

Re: Delete empty lines from a file

am 06.11.2007 12:18:00 von Stephane CHAZELAS

2007-11-06, 03:11(-08), shulamitm:
> I need to delete empty lines from a file (with spaces only - not null
> records). The following command works only for null rows, but not in
> case of spaces: sed '/^$/d' filename
[...]

grep '[^[:blank:]]' filename

awk NF filename

--
Stéphane

Re: Delete empty lines from a file

am 06.11.2007 12:35:54 von Cyrus Kriticos

shulamitm wrote:
>
> I need to delete empty lines from a file (with spaces only - not null
> records). The following command works only for null rows, but not in
> case of spaces: sed '/^$/d' filename

[GNU sed & grep]

sed '/^ \+$/d' filename

or

grep -v '^ \+$' filename

--
Best regards | Be nice to America or they'll bring democracy to
Cyrus | your country.

Re: Delete empty lines from a file

am 06.11.2007 12:39:09 von shulamitm

On Nov 6, 1:18 pm, Stephane CHAZELAS wrote:
> 2007-11-06, 03:11(-08), shulamitm:> I need to delete empty lines from a f=
ile (with spaces only - not null
> > records). The following command works only for null rows, but not in
> > case of spaces: sed '/^$/d' filename
>
> [...]
>
> grep '[^[:blank:]]' filename
>
> awk NF filename
>
> --
> St=E9phane

thanks!