<?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 -- last field replace in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/sed-last-field-replace/m-p/5023083#M762045</link>
    <description>Hi,&lt;BR /&gt;&lt;BR /&gt;it is not clear, if you want to have the additional string enclosed in double quotes or have the double quotes of the last field replaced.&lt;BR /&gt;&lt;BR /&gt;txt='hello"|"\388"|"376"|"meANDyou"'&lt;BR /&gt;First (Leave quotes):&lt;BR /&gt;echo $txt |sed 's/[^"]*"$/Z"/'&lt;BR /&gt;hello"|"\388"|"376"|"Z"&lt;BR /&gt;&lt;BR /&gt;Second (drop quotes):&lt;BR /&gt;echo $txt |sed 's/"[^"]*"$/Z/'&lt;BR /&gt;hello"|"\388"|"376"|Z&lt;BR /&gt;&lt;BR /&gt;mfG Peter</description>
    <pubDate>Wed, 17 Jan 2007 04:57:00 GMT</pubDate>
    <dc:creator>Peter Nikitka</dc:creator>
    <dc:date>2007-01-17T04:57:00Z</dc:date>
    <item>
      <title>sed -- last field replace</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sed-last-field-replace/m-p/5023080#M762042</link>
      <description>sed last field replace &lt;BR /&gt;&lt;BR /&gt;text file ...&lt;BR /&gt;hello"|"\388"|"376"|""&lt;BR /&gt;hello"|"\388"|"376"|"meANDyou"&lt;BR /&gt;&lt;BR /&gt;sed file &lt;BR /&gt;s/|""$/Z/g&lt;BR /&gt;&lt;BR /&gt;results ..&lt;BR /&gt;hello"|"meANDyou"|"\388"|"376"Z&lt;BR /&gt;hello"|"meANDyou"|"\388"|"376"|"meANDyou"&lt;BR /&gt;&lt;BR /&gt;using sed how  can I replace the "meANDyou" or any other quoted text or digits that is on the end of the line with a Z ?&lt;BR /&gt;&lt;BR /&gt;Steve</description>
      <pubDate>Tue, 16 Jan 2007 20:53:54 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sed-last-field-replace/m-p/5023080#M762042</guid>
      <dc:creator>Stephen Ray Badgett</dc:creator>
      <dc:date>2007-01-16T20:53:54Z</dc:date>
    </item>
    <item>
      <title>Re: sed -- last field replace</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sed-last-field-replace/m-p/5023081#M762043</link>
      <description>&lt;!--!*#--&gt;If you want to replace quoted text:&lt;BR /&gt;   sed -e 's/|".*"$/Z/'&lt;BR /&gt;&lt;BR /&gt;Did you want to replace quoted numbers or just raw numbers?  For the latter:&lt;BR /&gt;   sed -e 's/|[0-9]*$/Z/'&lt;BR /&gt;&lt;BR /&gt;And you can combine both -e patterns.&lt;BR /&gt;&lt;BR /&gt;Hmm, this doesn't work because it will replace your "\388" string too.  So you may need to use awk -f"|" and replace field $4.&lt;BR /&gt;&lt;BR /&gt;Or using this sed pattern assuming 4 fields with "|":&lt;BR /&gt;'s/\(.*\)|\(.*\)|\(.*\)|".*"$/\1|\2|\3|Z/'&lt;BR /&gt;&lt;BR /&gt;This takes the fields apart and only puts back the first 3.</description>
      <pubDate>Wed, 17 Jan 2007 02:20:55 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sed-last-field-replace/m-p/5023081#M762043</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2007-01-17T02:20:55Z</dc:date>
    </item>
    <item>
      <title>Re: sed -- last field replace</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sed-last-field-replace/m-p/5023082#M762044</link>
      <description>Steve,&lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;cat a.lis&lt;BR /&gt;awk -F'|' '{&lt;BR /&gt;for (i=1;i&lt;NF&gt;&lt;/NF&gt;printf "%s|",$i&lt;BR /&gt;printf "Z"&lt;BR /&gt;printf "\n";&lt;BR /&gt;}' &amp;lt; a.lis&lt;BR /&gt;&lt;BR /&gt;Produces:&lt;BR /&gt;hello"|"\388"|"376"|""&lt;BR /&gt;hello"|"\388"|"376"|"meANDyou"&lt;BR /&gt;hello"|"\388"|"376"|Z&lt;BR /&gt;hello"|"\388"|"376"|Z&lt;BR /&gt;&lt;BR /&gt;First two lines are the original input, next two the output.&lt;BR /&gt;&lt;BR /&gt;Please also read:&lt;BR /&gt;&lt;A href="http://forums1.itrc.hp.com/service/forums/helptips.do?#33" target="_blank"&gt;http://forums1.itrc.hp.com/service/forums/helptips.do?#33&lt;/A&gt; on how to reward any useful answers given to your questions. &lt;BR /&gt;&lt;BR /&gt;You currently have only awarded points to 1 of 23 answers.</description>
      <pubDate>Wed, 17 Jan 2007 03:07:41 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sed-last-field-replace/m-p/5023082#M762044</guid>
      <dc:creator>Peter Godron</dc:creator>
      <dc:date>2007-01-17T03:07:41Z</dc:date>
    </item>
    <item>
      <title>Re: sed -- last field replace</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sed-last-field-replace/m-p/5023083#M762045</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;it is not clear, if you want to have the additional string enclosed in double quotes or have the double quotes of the last field replaced.&lt;BR /&gt;&lt;BR /&gt;txt='hello"|"\388"|"376"|"meANDyou"'&lt;BR /&gt;First (Leave quotes):&lt;BR /&gt;echo $txt |sed 's/[^"]*"$/Z"/'&lt;BR /&gt;hello"|"\388"|"376"|"Z"&lt;BR /&gt;&lt;BR /&gt;Second (drop quotes):&lt;BR /&gt;echo $txt |sed 's/"[^"]*"$/Z/'&lt;BR /&gt;hello"|"\388"|"376"|Z&lt;BR /&gt;&lt;BR /&gt;mfG Peter</description>
      <pubDate>Wed, 17 Jan 2007 04:57:00 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sed-last-field-replace/m-p/5023083#M762045</guid>
      <dc:creator>Peter Nikitka</dc:creator>
      <dc:date>2007-01-17T04:57:00Z</dc:date>
    </item>
    <item>
      <title>Re: sed -- last field replace</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sed-last-field-replace/m-p/5023084#M762046</link>
      <description>Peter Nikitka...&lt;BR /&gt;&lt;BR /&gt;That works perfectly&lt;BR /&gt;&lt;BR /&gt;Thank you,&lt;BR /&gt;Steve</description>
      <pubDate>Wed, 17 Jan 2007 14:58:26 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sed-last-field-replace/m-p/5023084#M762046</guid>
      <dc:creator>Stephen Ray Badgett</dc:creator>
      <dc:date>2007-01-17T14:58:26Z</dc:date>
    </item>
    <item>
      <title>Re: sed -- last field replace</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sed-last-field-replace/m-p/5023085#M762047</link>
      <description>Peter Nikitka  &lt;BR /&gt;&lt;BR /&gt;Hd the answer I was needing and the other had solutions too :)</description>
      <pubDate>Wed, 17 Jan 2007 14:59:47 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sed-last-field-replace/m-p/5023085#M762047</guid>
      <dc:creator>Stephen Ray Badgett</dc:creator>
      <dc:date>2007-01-17T14:59:47Z</dc:date>
    </item>
  </channel>
</rss>

