<?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: sed: replace exact string (upper and lower cases) in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/sed-replace-exact-string-upper-and-lower-cases/m-p/6506030#M496591</link>
    <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;in the meantime i got support of a perl programer&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;perl -p -e 'while (/INTE/gi) { if (substr($_,$+[0]) !~/=/ &amp;amp;&amp;amp; substr($_,0,$-[0]) !~/#/) { s/INTE/INUA/; s/inte/inua/; } }' init.ora&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;the usage in a shell script will be ( i didn't a better solution) :&lt;/P&gt;&lt;PRE&gt;STRING_ACT="INUA"
STRING_OLD="INTE"
CHANGE_FILE="init.ora"

STRING_OLD_LOW=$(echo ${STRING_OLD} | tr '[:upper:]' '[:lower:]')
STRING_ACT_LOW=$(echo ${STRING_ACT} | tr '[:upper:]' '[:lower:]')

P_STRING_ACT="${STRING_ACT}" \
P_STRING_OLD="${STRING_OLD}" \
P_STRING_OLD_LOW="${STRING_OLD_LOW}" \
P_STRING_ACT_LOW="${STRING_ACT_LOW}" \
perl -i -p -e 'while (/$ENV{P_STRING_OLD}/gi) { if (substr($_,$+[0]) !~/=/ &amp;amp;&amp;amp; substr($_,0,$-[0]) !~/#/) { s/$ENV{P_STRING_OLD}/$ENV{P_STRING_ACT}/; s/$ENV{P_STRING_OLD_LOW}/$ENV{P_STRING_ACT_LOW}/; } }' ${CHANGE_FILE&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;i mean, the "sed" is easier to read.&lt;/P&gt;</description>
    <pubDate>Wed, 11 Jun 2014 06:54:55 GMT</pubDate>
    <dc:creator>support_billa</dc:creator>
    <dc:date>2014-06-11T06:54:55Z</dc:date>
    <item>
      <title>sed: replace exact string (upper and lower cases)</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sed-replace-exact-string-upper-and-lower-cases/m-p/6487774#M496589</link>
      <description>&lt;P&gt;hello,&lt;/P&gt;&lt;P&gt;i have a file ( parameter file of a database. filename: init.ora). the string length of the database sid are 4 characters.&lt;/P&gt;&lt;P&gt;database sid name is : INTE . i want to replace the sid name to a new sid name. i have combinations like:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;- INTE_inte or INTE or /INTE/ # comment&lt;/P&gt;&lt;P&gt;- but there are some strings like: query_rewrite_integrity ... this string also include "inte" , but this string i don't want to replace !&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;so i search for the string "INTE" or "inte"&lt;/P&gt;&lt;PRE&gt;grep -E "INTE[^A-Z]|INTE$|inte[^a-z]|inte$" init.ora&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;old replacement was ( not exact)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;sed -e "s|INTE|AAAA|g" -e "s|inte|aaaa|g"&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;but this statement works with Linux "sed" and not with HP-UX "sed" and didn't the right output:&lt;/P&gt;&lt;PRE&gt;sed -e "s/INTE\([^A-Z]\|$\)/AAAA\1/" -e "s/inte\([^a-z]\|$|\)/aaaa\1/" init.ora&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;are there any alternatives ? an example file is in the attachments, but you have to rename from init_ora.txt to init.ora&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;kind regards&lt;/P&gt;</description>
      <pubDate>Mon, 26 May 2014 21:28:31 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sed-replace-exact-string-upper-and-lower-cases/m-p/6487774#M496589</guid>
      <dc:creator>support_billa</dc:creator>
      <dc:date>2014-05-26T21:28:31Z</dc:date>
    </item>
    <item>
      <title>Re: sed: replace exact string (upper and lower cases)</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sed-replace-exact-string-upper-and-lower-cases/m-p/6488058#M496590</link>
      <description>&lt;P&gt;&amp;gt;are there any alternatives?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You're trying to use sed with EREs.&amp;nbsp; Instead repeat the script twice for each:&lt;/P&gt;&lt;P&gt;sed -e 's/INTE\([^A-Z]\)/AAAA\1/g' \&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; -e 's/INTE$/AAAA/' \&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; -e 's/inte\([^a-z]\)/aaaa\1/g' \&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; -e 's/inte$/aaaa/' \&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; init.ora&lt;/P&gt;</description>
      <pubDate>Tue, 27 May 2014 05:26:35 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sed-replace-exact-string-upper-and-lower-cases/m-p/6488058#M496590</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2014-05-27T05:26:35Z</dc:date>
    </item>
    <item>
      <title>Re: sed: replace exact string (upper and lower cases)</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sed-replace-exact-string-upper-and-lower-cases/m-p/6506030#M496591</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;in the meantime i got support of a perl programer&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;perl -p -e 'while (/INTE/gi) { if (substr($_,$+[0]) !~/=/ &amp;amp;&amp;amp; substr($_,0,$-[0]) !~/#/) { s/INTE/INUA/; s/inte/inua/; } }' init.ora&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;the usage in a shell script will be ( i didn't a better solution) :&lt;/P&gt;&lt;PRE&gt;STRING_ACT="INUA"
STRING_OLD="INTE"
CHANGE_FILE="init.ora"

STRING_OLD_LOW=$(echo ${STRING_OLD} | tr '[:upper:]' '[:lower:]')
STRING_ACT_LOW=$(echo ${STRING_ACT} | tr '[:upper:]' '[:lower:]')

P_STRING_ACT="${STRING_ACT}" \
P_STRING_OLD="${STRING_OLD}" \
P_STRING_OLD_LOW="${STRING_OLD_LOW}" \
P_STRING_ACT_LOW="${STRING_ACT_LOW}" \
perl -i -p -e 'while (/$ENV{P_STRING_OLD}/gi) { if (substr($_,$+[0]) !~/=/ &amp;amp;&amp;amp; substr($_,0,$-[0]) !~/#/) { s/$ENV{P_STRING_OLD}/$ENV{P_STRING_ACT}/; s/$ENV{P_STRING_OLD_LOW}/$ENV{P_STRING_ACT_LOW}/; } }' ${CHANGE_FILE&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;i mean, the "sed" is easier to read.&lt;/P&gt;</description>
      <pubDate>Wed, 11 Jun 2014 06:54:55 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sed-replace-exact-string-upper-and-lower-cases/m-p/6506030#M496591</guid>
      <dc:creator>support_billa</dc:creator>
      <dc:date>2014-06-11T06:54:55Z</dc:date>
    </item>
  </channel>
</rss>

