[comp.unix.questions] sed ? question

rkc@XN.LL.MIT.EDU (rkc) (05/26/89)

I have an application where I want to run a file through cpp and then 
strip that file of all the nasties that cpp generates, namely:
	1. Lines beginning "# line number info "
and 	2. The many blank lines.
It seems to me that sed should be able to do this for me--but I'm not sure how to go
about it.  I can get sed to do #1 by using the script:
	sed /^#/,/\n/d filename
but I can't figure out how to do #2.  Surely there is a sed guru out there who
can help me...(Add other pitiful cries for help.)
	Please e-mail responses, as I do not read this newsgroup.
	Thanks,
	 -Rob

mende@athos.rutgers.edu (Bob Mende Pie) (05/26/89)

In article <1415@xn.LL.MIT.EDU> rkc@XN.LL.MIT.EDU (rkc) writes:
> I have an application where I want to run a file through cpp and then 
> strip that file of all the nasties that cpp generates, namely:
> 	2. The many blank lines.

   to do this I use    egrep -v '^$'


					/Bob...
-- 

funk@osiris.cso.uiuc.edu (05/27/89)

> I have an application where I want to run a file through cpp and then 
> strip that file of all the nasties that cpp generates, namely:
> 	1. Lines beginning "# line number info "
> and 	2. The many blank lines.
> It seems to me that sed should be able to do this for me--
> but I can't figure out how to do #2.  Surely there is a sed guru out there who
> can help me...(Add other pitiful cries for help.)

Try  sed "/^ *$/d"
That will delete all lines consisting of  (only) any number of blnks

-------------------------------------------------------------------------------
|        Bruce Funk                         INTERNET: funk@osiris.cso.uiuc.edu |
|ACSEH, 21st TAACOM          __________________________________________________|
|Kaiserslautern, W. Germany  | Any resemblance between me and reality          |
|(guesting on osiris)        | is strictly coincidental                        |
-------------------------------------------------------------------------------

jeff@quark.WV.TEK.COM (Jeff Beadles) (05/27/89)

In article <May.25.18.16.13.1989.2763@athos.rutgers.edu> mende@athos.rutgers.edu (Bob Mende Pie) writes:
>In article <1415@xn.LL.MIT.EDU> rkc@XN.LL.MIT.EDU (rkc) writes:
>> I have an application where I want to run a file through cpp and then 
>> strip that file of all the nasties that cpp generates, namely:
>> 	2. The many blank lines.
>
>   to do this I use    egrep -v '^$'

This will not work if the line has any whitespace on it.  This should do
everything that he wants with one sed command.  The 2nd -e sequence will
delete any empty line, or one containing only white space.

cat file | sed -e '/^#.*$/d' -e '/^[ 	]*$/d'

There's a space and a tab between the []'s.

	-Jeff
--
Jeff Beadles		Utek Sustaining Engineering, Tektronix Inc.
jeff@quark.WV.TEK.COM