<?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: Script Explaination in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/script-explaination/m-p/4585947#M679382</link>
    <description>Hi Allan:&lt;BR /&gt;&lt;BR /&gt;# set -- `&amp;lt; /tmp/c.1`&lt;BR /&gt;&lt;BR /&gt;...sets the shell's positional parameters $1, etc. to the contents of the file '/tmp/c.1'.  If that contained a line with the string "a b c d e f", then $1 would be "a"; $2 would be "b", etc.&lt;BR /&gt;&lt;BR /&gt;A better form is:&lt;BR /&gt;&lt;BR /&gt;# set -- $(&lt;BR /&gt;...eliminating the archaic backtick syntax.&lt;BR /&gt;&lt;BR /&gt;# q=$*&lt;BR /&gt;&lt;BR /&gt;...simply creates a string called 'q' which contains all the positional paramters.&lt;BR /&gt;&lt;BR /&gt;# printf "%s\n" $(( ${q// / + } )) &amp;gt; /tmp/c.2&lt;BR /&gt;&lt;BR /&gt;...frankly, I don't quite know what this is attempting to do.  Post the contents of your input file.&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
    <pubDate>Wed, 17 Feb 2010 21:30:37 GMT</pubDate>
    <dc:creator>James R. Ferguson</dc:creator>
    <dc:date>2010-02-17T21:30:37Z</dc:date>
    <item>
      <title>Script Explaination</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-explaination/m-p/4585946#M679381</link>
      <description>I am looking at an old script which has the following text which I dont understand...&lt;BR /&gt;&lt;BR /&gt;set -- `&amp;lt; /tmp/c.1`&lt;BR /&gt;q=$*&lt;BR /&gt;printf "%s\n" $(( ${q// / + } )) &amp;gt; /tmp/c.2&lt;BR /&gt;&lt;BR /&gt;Can someone please explain what this is doing?&lt;BR /&gt;&lt;BR /&gt;Thanks,&lt;BR /&gt;Allan.</description>
      <pubDate>Wed, 17 Feb 2010 21:15:32 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-explaination/m-p/4585946#M679381</guid>
      <dc:creator>Allanm</dc:creator>
      <dc:date>2010-02-17T21:15:32Z</dc:date>
    </item>
    <item>
      <title>Re: Script Explaination</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-explaination/m-p/4585947#M679382</link>
      <description>Hi Allan:&lt;BR /&gt;&lt;BR /&gt;# set -- `&amp;lt; /tmp/c.1`&lt;BR /&gt;&lt;BR /&gt;...sets the shell's positional parameters $1, etc. to the contents of the file '/tmp/c.1'.  If that contained a line with the string "a b c d e f", then $1 would be "a"; $2 would be "b", etc.&lt;BR /&gt;&lt;BR /&gt;A better form is:&lt;BR /&gt;&lt;BR /&gt;# set -- $(&lt;BR /&gt;...eliminating the archaic backtick syntax.&lt;BR /&gt;&lt;BR /&gt;# q=$*&lt;BR /&gt;&lt;BR /&gt;...simply creates a string called 'q' which contains all the positional paramters.&lt;BR /&gt;&lt;BR /&gt;# printf "%s\n" $(( ${q// / + } )) &amp;gt; /tmp/c.2&lt;BR /&gt;&lt;BR /&gt;...frankly, I don't quite know what this is attempting to do.  Post the contents of your input file.&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Wed, 17 Feb 2010 21:30:37 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-explaination/m-p/4585947#M679382</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2010-02-17T21:30:37Z</dc:date>
    </item>
    <item>
      <title>Re: Script Explaination</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-explaination/m-p/4585948#M679383</link>
      <description>Hi (again) Allanm:&lt;BR /&gt;&lt;BR /&gt;OK, you're using a Bash shell, I believe.  The third statement sums numbers.  Blanks are converted to the operator needed to sume (the '+') and the whole expression is evaluated.  One could just as easily do subtraction or multiplication by changing the '=' to a '-' or '*' respectively.&lt;BR /&gt;&lt;BR /&gt;For instance, given:&lt;BR /&gt;&lt;BR /&gt;# set -- 1 2 3 4 5 6&lt;BR /&gt;# q=$*&lt;BR /&gt;# printf "%s\n" $(( ${q// / + } ))&lt;BR /&gt;21&lt;BR /&gt;&lt;BR /&gt;Or, with a bit of Perl:&lt;BR /&gt;&lt;BR /&gt;# echo ${q}|perl -nle '@a=split;print eval join "+",@a'&lt;BR /&gt;21&lt;BR /&gt;&lt;BR /&gt;As with the pure shell, one could do subtraction or multiplication by changing the '=' to a '-' or '*' respectively.&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Thu, 18 Feb 2010 13:02:13 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-explaination/m-p/4585948#M679383</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2010-02-18T13:02:13Z</dc:date>
    </item>
  </channel>
</rss>

