Den 2011-02-17 12:15 skrev Peter Rosin:
> Den 2011-02-15 21:19 skrev Ralf Wildenhues:
>> It's a bit of a shame this uses a temp file though.  awk should be able
>> to cope without (but be sure to try old Solaris awk if you go for it).
> 
> Ahh, who needs awk? :-)
> 
> unindent ()
> {
>   sed -n '
>     x
>     :useit
>     /./{
>       G
>       h
>       s/\n.*//
>       x
>       /x\(.*\)\n\1/s///p

The preceding line can be replaced by this slightly less convoluted thingy.

      s/x\(.*\)\n\1//p


>       s/.*\n//p
>       d
>     }
>     g
>     /^$/{
>       p
>       d
>     }
>     s/\([     ]*\).*/x\1/
>     b useit'
> }

Cheers,
Peter

Reply via email to