Re: Sed issue

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

 



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.
-- 
Cameron Simpson <cs@xxxxxxxxxx> DoD#743
http://www.cskk.ezoshosting.com/cs/

All my life, people have accused me of being stubborn, by which they meant
I was just standing there, when I could be taking their advice. - Adair Lara


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

  Powered by Linux