<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: script or sed/awk command to grep pattern and append line after it ? in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/script-or-sed-awk-command-to-grep-pattern-and-append-line-after/m-p/4900980#M404033</link>
    <description>Mel, Good answer. Got me thinking and made me find  utility of sed command. You answer will comment &lt;BR /&gt;out the line (what I wanted) but does not append abc.domain.com to &lt;BR /&gt;the the end of next line. (See #3 in my question above).&lt;BR /&gt;DSabc.domain.com. Thanks. &lt;BR /&gt;&lt;BR /&gt;Hein, Very Very close to what I wanted.   Your script commented out just #DS or $1 and ignored the rest of the line. But again,&lt;BR /&gt;I admit I did not explain correctly exactly what I wanted otherwise  you would have given me the exact answer and thus  you deserve full points.&lt;BR /&gt;Below is what I used which was just tweaking your command a little bit. Thanks Hein.&lt;BR /&gt;&lt;BR /&gt;perl -pi -e 'if (/^(DS)/) { print "#$_\n"; chop; $_ .="abc.domain.com\n"}' /etc/mail/sendmail.cf</description>
    <pubDate>Tue, 10 May 2005 08:29:51 GMT</pubDate>
    <dc:creator>Sammy_2</dc:creator>
    <dc:date>2005-05-10T08:29:51Z</dc:date>
    <item>
      <title>script or sed/awk command to grep pattern and append line after it ?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-or-sed-awk-command-to-grep-pattern-and-append-line-after/m-p/4900974#M404027</link>
      <description>How do I &lt;BR /&gt;1) grep for a pattern in a line beginning with (for instance : DS)&lt;BR /&gt;2) Comment out that line (for instance : #DS)&lt;BR /&gt;3) and append another line right after after it (for instance: DSabc.domain.com&lt;BR /&gt;&lt;BR /&gt;Basically modify /etc/mail/sendmail.cf file using a one line sed command or some script: &lt;BR /&gt;See below&lt;BR /&gt;&lt;BR /&gt;==========================&lt;BR /&gt;&lt;BR /&gt;###DS&lt;BR /&gt;DSmyname.domain.com&lt;BR /&gt;======================&lt;BR /&gt;&lt;BR /&gt;Thanks</description>
      <pubDate>Mon, 09 May 2005 15:30:57 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-or-sed-awk-command-to-grep-pattern-and-append-line-after/m-p/4900974#M404027</guid>
      <dc:creator>Sammy_2</dc:creator>
      <dc:date>2005-05-09T15:30:57Z</dc:date>
    </item>
    <item>
      <title>Re: script or sed/awk command to grep pattern and append line after it ?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-or-sed-awk-command-to-grep-pattern-and-append-line-after/m-p/4900975#M404028</link>
      <description>perl -pi -e 'if (s/^DS/#DS/) { print $_}; $_="DSabc.domain.com\n"' yourfile&lt;BR /&gt; &lt;BR /&gt;HTH&lt;BR /&gt; &lt;BR /&gt;-- Rod Hills</description>
      <pubDate>Mon, 09 May 2005 15:42:39 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-or-sed-awk-command-to-grep-pattern-and-append-line-after/m-p/4900975#M404028</guid>
      <dc:creator>Rodney Hills</dc:creator>
      <dc:date>2005-05-09T15:42:39Z</dc:date>
    </item>
    <item>
      <title>Re: script or sed/awk command to grep pattern and append line after it ?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-or-sed-awk-command-to-grep-pattern-and-append-line-after/m-p/4900976#M404029</link>
      <description>working variation:&lt;BR /&gt;$cat x&lt;BR /&gt;DS&lt;BR /&gt;xDS&lt;BR /&gt;DSx&lt;BR /&gt;$&lt;BR /&gt;$perl -pi -e 'if (/^(DS)/) { print "#$1\n"; chop; $_ .="abc.domain.com\n"}' x&lt;BR /&gt;$&lt;BR /&gt;$cat x&lt;BR /&gt;#DS&lt;BR /&gt;DSabc.domain.com&lt;BR /&gt;xDS&lt;BR /&gt;#DS&lt;BR /&gt;DSxabc.domain.com&lt;BR /&gt;&lt;BR /&gt;In this example one liner you only have to specify you select string once and it remembers and use it (in $1 and $_)&lt;BR /&gt;The data example includes a 'false' match to make you think about how you want to handle those cases.&lt;BR /&gt;&lt;BR /&gt;To latch onto just the search string on a line use: /^(DS)$/&lt;BR /&gt;&lt;BR /&gt;Hein.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Mon, 09 May 2005 16:14:58 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-or-sed-awk-command-to-grep-pattern-and-append-line-after/m-p/4900976#M404029</guid>
      <dc:creator>Hein van den Heuvel</dc:creator>
      <dc:date>2005-05-09T16:14:58Z</dc:date>
    </item>
    <item>
      <title>Re: script or sed/awk command to grep pattern and append line after it ?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-or-sed-awk-command-to-grep-pattern-and-append-line-after/m-p/4900977#M404030</link>
      <description>Rodney,&lt;BR /&gt;Thanks. But now my file only has many lines with just:&lt;BR /&gt;&lt;BR /&gt;DSabc.domain.com&lt;BR /&gt;DSabc.domain.com&lt;BR /&gt;DSabc.domain.com&lt;BR /&gt;...&lt;BR /&gt;..</description>
      <pubDate>Mon, 09 May 2005 16:15:26 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-or-sed-awk-command-to-grep-pattern-and-append-line-after/m-p/4900977#M404030</guid>
      <dc:creator>Sammy_2</dc:creator>
      <dc:date>2005-05-09T16:15:26Z</dc:date>
    </item>
    <item>
      <title>Re: script or sed/awk command to grep pattern and append line after it ?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-or-sed-awk-command-to-grep-pattern-and-append-line-after/m-p/4900978#M404031</link>
      <description>Hein,&lt;BR /&gt;You may have what I am looking for as I did a quick test. I will give it a shot tom. as I have to leave. But Thanks a bunch. I will post results tom.</description>
      <pubDate>Mon, 09 May 2005 16:19:57 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-or-sed-awk-command-to-grep-pattern-and-append-line-after/m-p/4900978#M404031</guid>
      <dc:creator>Sammy_2</dc:creator>
      <dc:date>2005-05-09T16:19:57Z</dc:date>
    </item>
    <item>
      <title>Re: script or sed/awk command to grep pattern and append line after it ?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-or-sed-awk-command-to-grep-pattern-and-append-line-after/m-p/4900979#M404032</link>
      <description>I am under the impression you are trying to comment out smart relay directives out of your sendmail.cf file. &lt;BR /&gt;&lt;BR /&gt;Here is how I do it without perl&lt;BR /&gt;&lt;BR /&gt;# sed -e "1,\$s/^DS/#DS/" /etc/mail/sendmail.cf &amp;gt; /tmp/sm.cf&lt;BR /&gt;# cat /tmp/sm.cf &amp;gt; /etc/mail/sendmail.cf&lt;BR /&gt;&lt;BR /&gt;this way, you do not mess up your file permissions for sendmail.cf&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Mon, 09 May 2005 16:35:27 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-or-sed-awk-command-to-grep-pattern-and-append-line-after/m-p/4900979#M404032</guid>
      <dc:creator>Mel Burslan</dc:creator>
      <dc:date>2005-05-09T16:35:27Z</dc:date>
    </item>
    <item>
      <title>Re: script or sed/awk command to grep pattern and append line after it ?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-or-sed-awk-command-to-grep-pattern-and-append-line-after/m-p/4900980#M404033</link>
      <description>Mel, Good answer. Got me thinking and made me find  utility of sed command. You answer will comment &lt;BR /&gt;out the line (what I wanted) but does not append abc.domain.com to &lt;BR /&gt;the the end of next line. (See #3 in my question above).&lt;BR /&gt;DSabc.domain.com. Thanks. &lt;BR /&gt;&lt;BR /&gt;Hein, Very Very close to what I wanted.   Your script commented out just #DS or $1 and ignored the rest of the line. But again,&lt;BR /&gt;I admit I did not explain correctly exactly what I wanted otherwise  you would have given me the exact answer and thus  you deserve full points.&lt;BR /&gt;Below is what I used which was just tweaking your command a little bit. Thanks Hein.&lt;BR /&gt;&lt;BR /&gt;perl -pi -e 'if (/^(DS)/) { print "#$_\n"; chop; $_ .="abc.domain.com\n"}' /etc/mail/sendmail.cf</description>
      <pubDate>Tue, 10 May 2005 08:29:51 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-or-sed-awk-command-to-grep-pattern-and-append-line-after/m-p/4900980#M404033</guid>
      <dc:creator>Sammy_2</dc:creator>
      <dc:date>2005-05-10T08:29:51Z</dc:date>
    </item>
    <item>
      <title>Re: script or sed/awk command to grep pattern and append line after it ?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-or-sed-awk-command-to-grep-pattern-and-append-line-after/m-p/4900981#M404034</link>
      <description>Thanks to  Rodney,  Hein and Mel.</description>
      <pubDate>Tue, 10 May 2005 08:30:32 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-or-sed-awk-command-to-grep-pattern-and-append-line-after/m-p/4900981#M404034</guid>
      <dc:creator>Sammy_2</dc:creator>
      <dc:date>2005-05-10T08:30:32Z</dc:date>
    </item>
  </channel>
</rss>

