<?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: replacing a charecter in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/replacing-a-charecter/m-p/5072958#M736083</link>
    <description>Use awk: &lt;BR /&gt;&lt;BR /&gt;echo abcdefg.dat | awk '{sub(/.dat/,".txt"); print}'&lt;BR /&gt;abcdefg.txt&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;In this case I substituted .dat with .txt&lt;BR /&gt;&lt;BR /&gt;regards,&lt;BR /&gt;ivan</description>
    <pubDate>Mon, 08 Oct 2007 09:10:55 GMT</pubDate>
    <dc:creator>Ivan Krastev</dc:creator>
    <dc:date>2007-10-08T09:10:55Z</dc:date>
    <item>
      <title>replacing a charecter</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/replacing-a-charecter/m-p/5072956#M736081</link>
      <description>Hi , &lt;BR /&gt;I have a variable with some value. eg,&lt;BR /&gt;&lt;BR /&gt;TestVar="abcdefg.dat"&lt;BR /&gt;&lt;BR /&gt;Using code i want to replace .dat to .txt &lt;BR /&gt;after replacement operation , the value of TestVar should be abcdefg.txt.&lt;BR /&gt;&lt;BR /&gt;Please help me to achieve this&lt;BR /&gt;</description>
      <pubDate>Mon, 08 Oct 2007 09:00:28 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/replacing-a-charecter/m-p/5072956#M736081</guid>
      <dc:creator>joseni</dc:creator>
      <dc:date>2007-10-08T09:00:28Z</dc:date>
    </item>
    <item>
      <title>Re: replacing a charecter</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/replacing-a-charecter/m-p/5072957#M736082</link>
      <description>Hi:&lt;BR /&gt;&lt;BR /&gt;# echo $TestVar|sed -e 's/\.dat$/\.txt/'&lt;BR /&gt;&lt;BR /&gt;Note that you must escape (backslash) the dot character in order for it to represent a dot and not any character.&lt;BR /&gt;&lt;BR /&gt;The dollar sign ($) character anchors the string to the end of the line for exact matching.&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...&lt;BR /&gt;</description>
      <pubDate>Mon, 08 Oct 2007 09:09:33 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/replacing-a-charecter/m-p/5072957#M736082</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2007-10-08T09:09:33Z</dc:date>
    </item>
    <item>
      <title>Re: replacing a charecter</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/replacing-a-charecter/m-p/5072958#M736083</link>
      <description>Use awk: &lt;BR /&gt;&lt;BR /&gt;echo abcdefg.dat | awk '{sub(/.dat/,".txt"); print}'&lt;BR /&gt;abcdefg.txt&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;In this case I substituted .dat with .txt&lt;BR /&gt;&lt;BR /&gt;regards,&lt;BR /&gt;ivan</description>
      <pubDate>Mon, 08 Oct 2007 09:10:55 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/replacing-a-charecter/m-p/5072958#M736083</guid>
      <dc:creator>Ivan Krastev</dc:creator>
      <dc:date>2007-10-08T09:10:55Z</dc:date>
    </item>
    <item>
      <title>Re: replacing a charecter</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/replacing-a-charecter/m-p/5072959#M736084</link>
      <description>Hi (again):&lt;BR /&gt;&lt;BR /&gt;Oh, and since you want a destructive update of the variable:&lt;BR /&gt;&lt;BR /&gt;# TestVar=$(echo $TestVar|sed -e 's/\.dat$/\.txt/')&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Mon, 08 Oct 2007 09:11:57 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/replacing-a-charecter/m-p/5072959#M736084</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2007-10-08T09:11:57Z</dc:date>
    </item>
    <item>
      <title>Re: replacing a charecter</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/replacing-a-charecter/m-p/5072960#M736085</link>
      <description>There are many ways to do this; here is one leveraging awk's gsub function.&lt;BR /&gt;&lt;BR /&gt;TestVar="abcdefg.dat"&lt;BR /&gt;NewVar=$(echo "${TestVar}" | awk '{gsub(".dat$",".txt"); print $0}')&lt;BR /&gt;echo "NewVar = ${NewVar}"&lt;BR /&gt;&lt;BR /&gt;Note the '$' at the end of the pattern match; this means that .dat will only be matched at the end of the string.</description>
      <pubDate>Mon, 08 Oct 2007 09:13:45 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/replacing-a-charecter/m-p/5072960#M736085</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2007-10-08T09:13:45Z</dc:date>
    </item>
    <item>
      <title>Re: replacing a charecter</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/replacing-a-charecter/m-p/5072961#M736086</link>
      <description>Thanks a lot for your support</description>
      <pubDate>Mon, 08 Oct 2007 09:15:45 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/replacing-a-charecter/m-p/5072961#M736086</guid>
      <dc:creator>joseni</dc:creator>
      <dc:date>2007-10-08T09:15:45Z</dc:date>
    </item>
    <item>
      <title>Re: replacing a charecter</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/replacing-a-charecter/m-p/5072962#M736087</link>
      <description>Hi:&lt;BR /&gt;&lt;BR /&gt;Welcome to the ITRC Forum!  As a new member, please see:&lt;BR /&gt;&lt;BR /&gt;&lt;A href="https://forums1.itrc.hp.com/service/forums/helptips.do?#28" target="_blank"&gt;https://forums1.itrc.hp.com/service/forums/helptips.do?#28&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Mon, 08 Oct 2007 09:22:20 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/replacing-a-charecter/m-p/5072962#M736087</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2007-10-08T09:22:20Z</dc:date>
    </item>
    <item>
      <title>Re: replacing a charecter</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/replacing-a-charecter/m-p/5072963#M736088</link>
      <description>i can't image no one suggested these:&lt;BR /&gt;&lt;BR /&gt;newvar="$(basename $testvar dat)txt"&lt;BR /&gt;or&lt;BR /&gt;newvar-"${testvar%dat}txt"</description>
      <pubDate>Mon, 08 Oct 2007 09:33:14 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/replacing-a-charecter/m-p/5072963#M736088</guid>
      <dc:creator>blah2blah</dc:creator>
      <dc:date>2007-10-08T09:33:14Z</dc:date>
    </item>
    <item>
      <title>Re: replacing a charecter</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/replacing-a-charecter/m-p/5072964#M736089</link>
      <description>Yep.  I just love those unassigned points.  I can't get enough of them.  Good think we what answers are helpful or bad because of those points. &lt;BR /&gt;&lt;BR /&gt;But I like mystery.  Did the answer really help?  Or will it destroy the computer?  The suspense is killing me.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;(sigh).&lt;BR /&gt;&lt;BR /&gt;Try the tr command too.   tr for transliterate.  &lt;BR /&gt;I use this to replace hex numbers with stuff I can see.&lt;BR /&gt;&lt;BR /&gt;Of course you can always use vi on a text file.  Run :%s/fromtext/totext/g to replace all "fromtext" phrases to "totext" on every occurance.  On every line.&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 09 Oct 2007 07:21:28 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/replacing-a-charecter/m-p/5072964#M736089</guid>
      <dc:creator>Steve Post</dc:creator>
      <dc:date>2007-10-09T07:21:28Z</dc:date>
    </item>
  </channel>
</rss>

