Sed issue

Dan Track dan.track at gmail.com
Mon Dec 4 12:59:01 UTC 2006


On 12/2/06, Cameron Simpson <cs at zip.com.au> wrote:
> On 01Dec2006 08:27, David G. Miller <dave at davenjudy.org> wrote:
> | Why use sed?  How about:
> |
> | cat file | head --lines=-3 | awk '{if (/-----BEGIN PGP SIGNATURE-----/)
> | exit; print $0;}'
>
> You example is a prime reason to use sed! It is long, complex and runs
> three programs!
>
> You can replace "cat file | head --lines=-3" with:
>
>   sed 1,3d
>
> You can replace the entire awk command with:
>
>   sed '/-----BEGIN PGP SIGNATURE-----/{d;q}'
>
> You can replace your entire command pipeline with:
>
>   sed '1,3d; /-----BEGIN PGP SIGNATURE-----/{d;q}'
>
> And _that_ is why you'd use sed for this.
> --

Hi

Many thanks for all your replies. It was interesting at the least to
see different ways of doing this.

Thanks again
Dan




More information about the fedora-list mailing list