Afficher un message
Vieux 24/05/2007, 16h59   #3
Bill Marcum
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Remove empty lines using sed, with exceptions

On 23 May 2007 23:55:22 -0700, Leif
<leifwessman@hotmail.com> wrote:
>
>
>
> How can I remove all newlines with exceptions?
>
> This is a part of my text. I would like to remove all newlines. But
> newlines should be kept if the next line starts with '/*@' or if the
> current line starts with '/*@'.
>
> -----------
> e.stopPropagation();
> e.preventDefault();
>
> /*@cc_on
>
>
> /*@if (@_win32)
>
> e.cancelBubble=true;
> e.returnValue=false;
>
> /*@end
> -----------
>
> what I want:
>
> -----------
> e.stopPropagation();e.preventDefault();
> /*@cc_on
> /*@if (@_win32)
> e.cancelBubble=true;e.returnValue=false;
> /*@end
> -----------
>
> I'm guessing this would need two steps. 1) remove all newlines 2)
> insert newlines
> Could someone me figure out what sed command I should use for 2)?
>
> #!/bin/sh
> cat a.js b.js c.js > /tmp/combined.js
> cat /tmp/combined.js | sed -e 'N;s/\n//;P;D;' | sed -e "????" > out.js
>


cat a.js b.js c.js | tr -d '\n' | sed -e 's|/\*@|
/*@' >out.js


--
The discerning person is always at a disadvantage.
  Réponse avec citation
 
Page generated in 0,04982 seconds with 9 queries