sed woes

Daniel teletautala at gmail.com
Thu Dec 14 10:53:30 MST 2006


I am trying to remove the second occurance of the match.  All the
documentation I read says this is how you do it.  For me it either is
global or does not work.  Is there a different way of doing this?
Would awk be better?

This some relavent lines from my hosts.deny file:
=== snipit ===
ALL:125.206.122.49
ALL:211.94.73.199
ALL:213.215.228.250
ALL:213.215.228.250
ALL:211.94.73.199
ALL:211.94.73.199
ALL:71.213.9.247
=== snipit ===

sed -e 's/ALL:211\.94\.73\.199//' /etc/hosts.deny
   results in the following:
=== snipit ===
ALL:125.206.122.49

ALL:213.215.228.250
ALL:213.215.228.250


ALL:71.213.9.247
=== snipit ===

sed -e 's/ALL:211\.94\.73\.199//1' /etc/hosts.deny
  results in the following:
=== snipit ===
ALL:125.206.122.49

ALL:213.215.228.250
ALL:213.215.228.250


ALL:71.213.9.247
=== snipit ===

sed -e 's/ALL:211\.94\.73\.199//2' /etc/hosts.deny
  results in the following:
=== snipit ===
ALL:125.206.122.49
ALL:211.94.73.199
ALL:213.215.228.250
ALL:213.215.228.250
ALL:211.94.73.199
ALL:211.94.73.199
ALL:71.213.9.247
=== snipit ===

What am I doing wrong?  How can I get the resulting empty line to be
removed as well?

-Daniel



More information about the PLUG mailing list