<?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: urgent : Korn shell programmig using set in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/urgent-korn-shell-programmig-using-set/m-p/2494231#M830438</link>
    <description>Hi friends,&lt;BR /&gt;&lt;BR /&gt;Thanks for your help in resolving the problem.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;-Bala</description>
    <pubDate>Wed, 21 Feb 2001 16:29:24 GMT</pubDate>
    <dc:creator>Balasubramanian</dc:creator>
    <dc:date>2001-02-21T16:29:24Z</dc:date>
    <item>
      <title>urgent : Korn shell programmig using set</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/urgent-korn-shell-programmig-using-set/m-p/2494227#M830434</link>
      <description>Hi all,&lt;BR /&gt;&lt;BR /&gt;I am using set array option to store the records into fields and then compare.&lt;BR /&gt;&lt;BR /&gt;What exactly happening is when the &lt;BR /&gt;&lt;BR /&gt;field contains null spaces. the array is truncating it.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;For ex. when the field contains the value&lt;BR /&gt;"1         ", the array truncates the remaining spaces after 1. But i want to compare as it is with out truncation using&lt;BR /&gt;set -A option.&lt;BR /&gt;&lt;BR /&gt;How to avoid truncation of fields with trailing null spaces ?&lt;BR /&gt;&lt;BR /&gt;Because of this truncation i am getting wrong results.&lt;BR /&gt;&lt;BR /&gt;One more thing what i need is, &lt;BR /&gt;&lt;BR /&gt;when the field value is more than expected length, i have to truncate to specified length.&lt;BR /&gt;&lt;BR /&gt;For ex.&lt;BR /&gt;&lt;BR /&gt;set -A fields2 $(print "$line2" | tr "\|" " "&lt;BR /&gt;&lt;BR /&gt;fieldlen=`expr length "${fields3[$y]}"`&lt;BR /&gt;&lt;BR /&gt;if [ $fieldlen -gt 12 ]&lt;BR /&gt;then&lt;BR /&gt;fields2[$y]=`expr substr "${fields2[$y]}" 1 12`&lt;BR /&gt;else&lt;BR /&gt;:&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Can i assign the value to array of strings this way ? &lt;BR /&gt;&lt;BR /&gt;How do i reassign the value to an array ?&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;I have given below the sample code.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;####Sample Code ####&lt;BR /&gt;&lt;BR /&gt;exec 3 &amp;lt; file1&lt;BR /&gt;&lt;BR /&gt;exec 5 &amp;lt; file2&lt;BR /&gt;&lt;BR /&gt;while read -u3 line1&lt;BR /&gt;do&lt;BR /&gt;&lt;BR /&gt;no_of_fields=`echo $line1" | awk '{ FS = "|" } { print NF }`&lt;BR /&gt;&lt;BR /&gt;set -A fields1 $(print "$line1" | tr "\|" " ")&lt;BR /&gt;&lt;BR /&gt;while read -u5 line2&lt;BR /&gt;do&lt;BR /&gt;&lt;BR /&gt;set -A fields2 $(print "$line2" | tr "\|" " "&lt;BR /&gt;count=$no_of_fields&lt;BR /&gt;cmpfile3=0&lt;BR /&gt;y=0&lt;BR /&gt;while [ $count -gt 0 ]&lt;BR /&gt;do&lt;BR /&gt;&lt;BR /&gt;fieldlen=`expr length "${fields3[$y]}"`&lt;BR /&gt;&lt;BR /&gt;if [ $fieldlen -gt 12 ]&lt;BR /&gt;then&lt;BR /&gt;fields1[$y]=`expr substr "${fields1[$y]}" 1 12`&lt;BR /&gt;fields3[$y]=`expr substr "${fields3[$y]}" 1 12`&lt;BR /&gt;else&lt;BR /&gt;:&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;........&lt;BR /&gt;&lt;BR /&gt;#########&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Awaiting your reply.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Thanks&lt;BR /&gt;Bala</description>
      <pubDate>Thu, 15 Feb 2001 15:19:07 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/urgent-korn-shell-programmig-using-set/m-p/2494227#M830434</guid>
      <dc:creator>Balasubramanian</dc:creator>
      <dc:date>2001-02-15T15:19:07Z</dc:date>
    </item>
    <item>
      <title>Re: urgent : Korn shell programmig using set</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/urgent-korn-shell-programmig-using-set/m-p/2494228#M830435</link>
      <description>Hi:&lt;BR /&gt;&lt;BR /&gt;&amp;gt; To preserve spaces as a legitimate field, change your IFS variable in your script, like:&lt;BR /&gt;&lt;BR /&gt;IFS=:  #...changes the inter-field-separator from the standard space to the colon character.&lt;BR /&gt;&lt;BR /&gt;&amp;gt; To change the value of an array element, do, for example:&lt;BR /&gt;&lt;BR /&gt;ARY[3]=" XYZ "&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Thu, 15 Feb 2001 15:38:13 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/urgent-korn-shell-programmig-using-set/m-p/2494228#M830435</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2001-02-15T15:38:13Z</dc:date>
    </item>
    <item>
      <title>Re: urgent : Korn shell programmig using set</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/urgent-korn-shell-programmig-using-set/m-p/2494229#M830436</link>
      <description>Bala,&lt;BR /&gt;&lt;BR /&gt;First question: this is what I have:&lt;BR /&gt;&lt;BR /&gt;$ set -A arrTest " 1 "&lt;BR /&gt;$ echo --${arrTest[0]}--&lt;BR /&gt;--1--&lt;BR /&gt;$ IFS=""&lt;BR /&gt;$ set -A arrTest " 1 "&lt;BR /&gt;$ echo --${arrTest[0]}--&lt;BR /&gt;-- 1 --&lt;BR /&gt;$ unset IFS&lt;BR /&gt;&lt;BR /&gt;Is that what you desire??&lt;BR /&gt;&lt;BR /&gt;Do not forget to unset IFS after you're ready with it. For more info on IFS, check out the sh-posix manpage.&lt;BR /&gt;&lt;BR /&gt;Hope this helps,&lt;BR /&gt;Rik&lt;BR /&gt;</description>
      <pubDate>Thu, 15 Feb 2001 15:41:39 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/urgent-korn-shell-programmig-using-set/m-p/2494229#M830436</guid>
      <dc:creator>RikTytgat</dc:creator>
      <dc:date>2001-02-15T15:41:39Z</dc:date>
    </item>
    <item>
      <title>Re: urgent : Korn shell programmig using set</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/urgent-korn-shell-programmig-using-set/m-p/2494230#M830437</link>
      <description>Bala,&lt;BR /&gt;&lt;BR /&gt;For your field length problem, you might try to substr before storing the variables into the array.&lt;BR /&gt;&lt;BR /&gt;set -A fields $(echo $line | awk '{ for (i=1;i&amp;lt;=NF;i++) print substr($i,1,12) }')&lt;BR /&gt;&lt;BR /&gt;This should limit every word on $line to 12 characters.&lt;BR /&gt;&lt;BR /&gt;Hope this is what you want,&lt;BR /&gt;Rik.</description>
      <pubDate>Thu, 15 Feb 2001 15:50:01 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/urgent-korn-shell-programmig-using-set/m-p/2494230#M830437</guid>
      <dc:creator>RikTytgat</dc:creator>
      <dc:date>2001-02-15T15:50:01Z</dc:date>
    </item>
    <item>
      <title>Re: urgent : Korn shell programmig using set</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/urgent-korn-shell-programmig-using-set/m-p/2494231#M830438</link>
      <description>Hi friends,&lt;BR /&gt;&lt;BR /&gt;Thanks for your help in resolving the problem.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;-Bala</description>
      <pubDate>Wed, 21 Feb 2001 16:29:24 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/urgent-korn-shell-programmig-using-set/m-p/2494231#M830438</guid>
      <dc:creator>Balasubramanian</dc:creator>
      <dc:date>2001-02-21T16:29:24Z</dc:date>
    </item>
    <item>
      <title>Re: urgent : Korn shell programmig using set</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/urgent-korn-shell-programmig-using-set/m-p/2494232#M830439</link>
      <description>Hi Bala,&lt;BR /&gt;&lt;BR /&gt;It's nice to say 'Thanks' but it would be a lot nicer if you assigned points to the people who spent some time (or a lot of) to help you.&lt;BR /&gt;&lt;BR /&gt;Thanks for them,&lt;BR /&gt;&lt;BR /&gt;No point for me please ! &lt;BR /&gt;&lt;BR /&gt;Dan&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 22 Feb 2001 06:17:20 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/urgent-korn-shell-programmig-using-set/m-p/2494232#M830439</guid>
      <dc:creator>Dan Hetzel</dc:creator>
      <dc:date>2001-02-22T06:17:20Z</dc:date>
    </item>
    <item>
      <title>Re: urgent : Korn shell programmig using set</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/urgent-korn-shell-programmig-using-set/m-p/2494233#M830440</link>
      <description>Have you read man sh-posix?&lt;BR /&gt;&lt;BR /&gt;A world of posibilities:&lt;BR /&gt;&lt;BR /&gt;From man sh-posix  &lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;  &amp;amp; typeset [{-|+}LRZfilrtux[n]] [name[=value]]...                                                                   &lt;BR /&gt;      name=value [name=value]...                                                                &lt;BR /&gt;                                                                                                                                    &lt;BR /&gt;           Assign types and a value to a local named parameter name.  See               &lt;BR /&gt;           also the export special command.  Parameter assignments remain in &lt;BR /&gt;           function, create a new instance of the parameter name.  The               &lt;BR /&gt;           parameter value and type are restored when the function                                                                  &lt;BR /&gt;           completes.                                                                                      &lt;BR /&gt;                                                                                                               &lt;BR /&gt;           The following list of attributes can be specified.  Use + instead          &lt;BR /&gt;           of - to turn the options off.                                                               &lt;BR /&gt;                                                                                                               &lt;BR /&gt;           -L   Left justify and remove leading blanks from value.  If n is              &lt;BR /&gt;                nonzero, it defines the width of the field; otherwise, it is                &lt;BR /&gt;                determined by the width of the value of first assignment.               &lt;BR /&gt;                When name is assigned, the value is filled on the right with           &lt;BR /&gt;                blanks or truncated, if necessary, to fit into the field.                     &lt;BR /&gt;                Leading zeros are removed if the -Z option is also set.  The           &lt;BR /&gt;                -R option is turned off.  Flagged as leftjust n.                                &lt;BR /&gt;                                                                                                                &lt;BR /&gt;           -R   Right justify and fill with leading blanks.  If n is                            &lt;BR /&gt;                nonzero, it defines the width of the field; otherwise, it is                 &lt;BR /&gt;                determined by the width of the value of first assignment.                &lt;BR /&gt;                The field is left-filled with blanks or truncated from the                    &lt;BR /&gt;                end if the parameter is reassigned.  The -L option is turned            &lt;BR /&gt;                off.  Flagged as rightjust n.                                                         &lt;BR /&gt;                                                                                                                &lt;BR /&gt;           -Z   Right justify and fill with leading zeros if the first                          &lt;BR /&gt;                nonblank character is a digit and the -L option has not been     &lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;:-))</description>
      <pubDate>Thu, 22 Feb 2001 16:24:29 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/urgent-korn-shell-programmig-using-set/m-p/2494233#M830440</guid>
      <dc:creator>Carlos Fernandez Riera</dc:creator>
      <dc:date>2001-02-22T16:24:29Z</dc:date>
    </item>
  </channel>
</rss>

