Re: Sed issue

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 12/2/06, Cameron Simpson <cs@xxxxxxxxxx> wrote:
On 01Dec2006 08:27, David G. Miller <dave@xxxxxxxxxxxxx> 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


[Index of Archives]     [Current Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]     [Fedora Docs]

  Powered by Linux