<?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 storing columns in different variables in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/storing-columns-in-different-variables/m-p/3198057#M792248</link>
    <description>Hi,&lt;BR /&gt;&lt;BR /&gt;Please find attached a file which has 2 columns. I need to store the column values in 2 different variables and use them in a SHELL script. I have an excutable which takes the coulmn values as parameters.&lt;BR /&gt;&lt;BR /&gt;Thanks,&lt;BR /&gt;Andy&lt;BR /&gt;&lt;BR /&gt;</description>
    <pubDate>Fri, 20 Feb 2004 12:43:46 GMT</pubDate>
    <dc:creator>Anand_30</dc:creator>
    <dc:date>2004-02-20T12:43:46Z</dc:date>
    <item>
      <title>storing columns in different variables</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/storing-columns-in-different-variables/m-p/3198057#M792248</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;Please find attached a file which has 2 columns. I need to store the column values in 2 different variables and use them in a SHELL script. I have an excutable which takes the coulmn values as parameters.&lt;BR /&gt;&lt;BR /&gt;Thanks,&lt;BR /&gt;Andy&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Fri, 20 Feb 2004 12:43:46 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/storing-columns-in-different-variables/m-p/3198057#M792248</guid>
      <dc:creator>Anand_30</dc:creator>
      <dc:date>2004-02-20T12:43:46Z</dc:date>
    </item>
    <item>
      <title>Re: storing columns in different variables</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/storing-columns-in-different-variables/m-p/3198058#M792249</link>
      <description>Trivially simple:&lt;BR /&gt;&lt;BR /&gt;MYFILE=myfile.txt&lt;BR /&gt;&lt;BR /&gt;cat ${MYFILE} | while read A B&lt;BR /&gt;  do&lt;BR /&gt;    echo "A = \"${A}\" B = \"${B}\""&lt;BR /&gt;  done&lt;BR /&gt;</description>
      <pubDate>Fri, 20 Feb 2004 12:48:58 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/storing-columns-in-different-variables/m-p/3198058#M792249</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2004-02-20T12:48:58Z</dc:date>
    </item>
    <item>
      <title>Re: storing columns in different variables</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/storing-columns-in-different-variables/m-p/3198059#M792250</link>
      <description>Clay's script is, as he said, trivially simple.  Its is limited to parsing the table from the beginning to the end.  But what if you wanted to start at the end, and work up to the beginning?  Here's a (probably needlessly) complex way to do this:&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/ksh&lt;BR /&gt;LENGTH=`wc -l $FILE|awk '{ print $1 }'`&lt;BR /&gt;while test "$LENGTH" -ge "1"&lt;BR /&gt;do&lt;BR /&gt;     LINE=`head -"$LENGTH" $FILE|tail -1`&lt;BR /&gt;     A=`echo $LINE|awk '{ print $1 }'`&lt;BR /&gt;     B=`echo $LINE|awk '{ print $2 }'`&lt;BR /&gt;     (( LENGTH = "$LENGTH" - "1" ))&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;Another advantage (if there is one) is that not every version of Unix has the read command.  But every one that I've ever seen has head, tail, and awk.  Some versions (System V derivations, like old SCO) don't have wc either.  If so, use &lt;BR /&gt;LENGTH=`pr -n -t $FILE|tail -1|awk '{ print $1 }'`&lt;BR /&gt;instead of the previous LENGTH statement.  This uses up a lot more clock cycles than Clays script, but is portable across every version of Unix that I've ever seen.  Its handy for log files.&lt;BR /&gt;  &lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Chris</description>
      <pubDate>Fri, 20 Feb 2004 16:50:01 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/storing-columns-in-different-variables/m-p/3198059#M792250</guid>
      <dc:creator>Chris Vail</dc:creator>
      <dc:date>2004-02-20T16:50:01Z</dc:date>
    </item>
    <item>
      <title>Re: storing columns in different variables</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/storing-columns-in-different-variables/m-p/3198060#M792251</link>
      <description>Hi,&lt;BR /&gt;this will probably also work:&lt;BR /&gt;&lt;BR /&gt;# A=$(cut -f1 infile)&lt;BR /&gt;# B=$(cut -f2 infile1)&lt;BR /&gt; &lt;BR /&gt;regards,&lt;BR /&gt;John K.&lt;BR /&gt;</description>
      <pubDate>Sat, 21 Feb 2004 03:49:44 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/storing-columns-in-different-variables/m-p/3198060#M792251</guid>
      <dc:creator>john korterman</dc:creator>
      <dc:date>2004-02-21T03:49:44Z</dc:date>
    </item>
  </channel>
</rss>

