Sed issue
Cameron Simpson
cs at zip.com.au
Sat Dec 2 03:28:01 UTC 2006
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.
--
Cameron Simpson <cs at zip.com.au> 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
More information about the fedora-list
mailing list