<?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: How to extract last character in a variable in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/how-to-extract-last-character-in-a-variable/m-p/3086438#M143807</link>
    <description>Hi,&lt;BR /&gt; &lt;BR /&gt;Here is one way to get it using awk:&lt;BR /&gt; &lt;BR /&gt;V1=25386&lt;BR /&gt;V2=$(echo $V1 | awk '{print substr($1, length($1), 1)}'&lt;BR /&gt; &lt;BR /&gt;The local wizards will probably post some more elegant methods for you, but this is how one poor sysadmin would try it.&lt;BR /&gt; &lt;BR /&gt;JP&lt;BR /&gt;</description>
    <pubDate>Mon, 06 Oct 2003 15:16:32 GMT</pubDate>
    <dc:creator>John Poff</dc:creator>
    <dc:date>2003-10-06T15:16:32Z</dc:date>
    <item>
      <title>How to extract last character in a variable</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/how-to-extract-last-character-in-a-variable/m-p/3086436#M143805</link>
      <description>I have a variable "V1" that contains a number of numeric characters and I would like to set "V2" to be the last character in V1.  How can I do this in ksh script. (Example:  V1=25386, would like to get V2=6)</description>
      <pubDate>Mon, 06 Oct 2003 15:03:53 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/how-to-extract-last-character-in-a-variable/m-p/3086436#M143805</guid>
      <dc:creator>Tom Krocak_1</dc:creator>
      <dc:date>2003-10-06T15:03:53Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract last character in a variable</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/how-to-extract-last-character-in-a-variable/m-p/3086437#M143806</link>
      <description>POS=`echo $V1 | wc -m`&lt;BR /&gt;#acct for newline&lt;BR /&gt;let POS=$POS-1&lt;BR /&gt;V2=`echo $V1 | cut -c $POS`&lt;BR /&gt;&lt;BR /&gt;Quick and dirty, but it works.&lt;BR /&gt;HTH.</description>
      <pubDate>Mon, 06 Oct 2003 15:15:41 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/how-to-extract-last-character-in-a-variable/m-p/3086437#M143806</guid>
      <dc:creator>Brian Bergstrand</dc:creator>
      <dc:date>2003-10-06T15:15:41Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract last character in a variable</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/how-to-extract-last-character-in-a-variable/m-p/3086438#M143807</link>
      <description>Hi,&lt;BR /&gt; &lt;BR /&gt;Here is one way to get it using awk:&lt;BR /&gt; &lt;BR /&gt;V1=25386&lt;BR /&gt;V2=$(echo $V1 | awk '{print substr($1, length($1), 1)}'&lt;BR /&gt; &lt;BR /&gt;The local wizards will probably post some more elegant methods for you, but this is how one poor sysadmin would try it.&lt;BR /&gt; &lt;BR /&gt;JP&lt;BR /&gt;</description>
      <pubDate>Mon, 06 Oct 2003 15:16:32 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/how-to-extract-last-character-in-a-variable/m-p/3086438#M143807</guid>
      <dc:creator>John Poff</dc:creator>
      <dc:date>2003-10-06T15:16:32Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract last character in a variable</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/how-to-extract-last-character-in-a-variable/m-p/3086439#M143808</link>
      <description>Thanks - I like both answers.</description>
      <pubDate>Mon, 06 Oct 2003 15:39:33 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/how-to-extract-last-character-in-a-variable/m-p/3086439#M143808</guid>
      <dc:creator>Tom Krocak_1</dc:creator>
      <dc:date>2003-10-06T15:39:33Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract last character in a variable</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/how-to-extract-last-character-in-a-variable/m-p/3086440#M143809</link>
      <description>cant remember which will work for your case,&lt;BR /&gt;but -L is left justified and -R is right justified.  (not even sure if this is supported on hp's old 88 version of the korn shell).  &lt;BR /&gt;&lt;BR /&gt;typeset -L 1 v2=$v1&lt;BR /&gt;or&lt;BR /&gt;typeset -R 1 v2=$v1&lt;BR /&gt;&lt;BR /&gt;if it is support one of these will work</description>
      <pubDate>Mon, 06 Oct 2003 15:39:35 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/how-to-extract-last-character-in-a-variable/m-p/3086440#M143809</guid>
      <dc:creator>curt larson_1</dc:creator>
      <dc:date>2003-10-06T15:39:35Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract last character in a variable</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/how-to-extract-last-character-in-a-variable/m-p/3086441#M143810</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;You can employ the modulo technique in math as follows:&lt;BR /&gt;&lt;BR /&gt;V2=`echo $V1%10 | bc`&lt;BR /&gt;echo $V2&lt;BR /&gt;&lt;BR /&gt;Hope this helps.&lt;BR /&gt;&lt;BR /&gt;Hai</description>
      <pubDate>Mon, 06 Oct 2003 15:41:07 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/how-to-extract-last-character-in-a-variable/m-p/3086441#M143810</guid>
      <dc:creator>Hai Nguyen_1</dc:creator>
      <dc:date>2003-10-06T15:41:07Z</dc:date>
    </item>
  </channel>
</rss>

