<?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: Awk and assigning values to multiple variables in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-and-assigning-values-to-multiple-variables/m-p/4876349#M707922</link>
    <description>That is another way, but I have 13 to do.  I'm looking for the most efficient way.  What do you think about doing 13 variables that way?</description>
    <pubDate>Tue, 21 Dec 2004 08:47:07 GMT</pubDate>
    <dc:creator>Scott Frye_1</dc:creator>
    <dc:date>2004-12-21T08:47:07Z</dc:date>
    <item>
      <title>Awk and assigning values to multiple variables</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-and-assigning-values-to-multiple-variables/m-p/4876347#M707920</link>
      <description>I have a simple need that I know I can resolve with a loop but I want to know if there is a way to do it without looping.&lt;BR /&gt;&lt;BR /&gt;My file has one line from TOP&lt;BR /&gt;0   ?       37 root     152 20     0K  1888K run    247:32  0.58  0.58 vxfsd&lt;BR /&gt;&lt;BR /&gt;All I want to do is assign each piece of this line to a seperate variable.  I could do&lt;BR /&gt;awk'{print $1" "$2 " "$3}' toptest.txt | while read var1 var2 var3; do&lt;BR /&gt;do whatever&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;but I would like to stay away from the loop since there is (and will only be) one line of data</description>
      <pubDate>Tue, 21 Dec 2004 08:37:23 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-and-assigning-values-to-multiple-variables/m-p/4876347#M707920</guid>
      <dc:creator>Scott Frye_1</dc:creator>
      <dc:date>2004-12-21T08:37:23Z</dc:date>
    </item>
    <item>
      <title>Re: Awk and assigning values to multiple variables</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-and-assigning-values-to-multiple-variables/m-p/4876348#M707921</link>
      <description>var1=$(awk'{print $1}' toptest.txt)&lt;BR /&gt;var2=$(awk'{print $2}' toptest.txt)&lt;BR /&gt;var3=$(awk'{print $3}' toptest.txt)&lt;BR /&gt;&lt;BR /&gt;This should populate the variables without using a loop.&lt;BR /&gt;&lt;BR /&gt;SEP</description>
      <pubDate>Tue, 21 Dec 2004 08:45:42 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-and-assigning-values-to-multiple-variables/m-p/4876348#M707921</guid>
      <dc:creator>Steven E. Protter</dc:creator>
      <dc:date>2004-12-21T08:45:42Z</dc:date>
    </item>
    <item>
      <title>Re: Awk and assigning values to multiple variables</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-and-assigning-values-to-multiple-variables/m-p/4876349#M707922</link>
      <description>That is another way, but I have 13 to do.  I'm looking for the most efficient way.  What do you think about doing 13 variables that way?</description>
      <pubDate>Tue, 21 Dec 2004 08:47:07 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-and-assigning-values-to-multiple-variables/m-p/4876349#M707922</guid>
      <dc:creator>Scott Frye_1</dc:creator>
      <dc:date>2004-12-21T08:47:07Z</dc:date>
    </item>
    <item>
      <title>Re: Awk and assigning values to multiple variables</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-and-assigning-values-to-multiple-variables/m-p/4876350#M707923</link>
      <description>being your file has just one line,&lt;BR /&gt;the simplest way with just using the shell, would be:&lt;BR /&gt;cat file | read var1 var2 var3 rest&lt;BR /&gt;print "$var1 $var2 $var3" #just to test&lt;BR /&gt;&lt;BR /&gt;and if you don't mind reading from right to left:&lt;BR /&gt;&lt;BR /&gt;read var1 var2 var3 rest &amp;lt; yourfile</description>
      <pubDate>Tue, 21 Dec 2004 09:30:36 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-and-assigning-values-to-multiple-variables/m-p/4876350#M707923</guid>
      <dc:creator>c_51</dc:creator>
      <dc:date>2004-12-21T09:30:36Z</dc:date>
    </item>
    <item>
      <title>Re: Awk and assigning values to multiple variables</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-and-assigning-values-to-multiple-variables/m-p/4876351#M707924</link>
      <description>I think that you can do:&lt;BR /&gt;&lt;BR /&gt;cat file | while read v1 v2 v3 ... v13&lt;BR /&gt;do&lt;BR /&gt;  commands&lt;BR /&gt;end</description>
      <pubDate>Tue, 21 Dec 2004 09:32:30 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-and-assigning-values-to-multiple-variables/m-p/4876351#M707924</guid>
      <dc:creator>Stuart Abramson</dc:creator>
      <dc:date>2004-12-21T09:32:30Z</dc:date>
    </item>
    <item>
      <title>Re: Awk and assigning values to multiple variables</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-and-assigning-values-to-multiple-variables/m-p/4876352#M707925</link>
      <description>Hi,&lt;BR /&gt;what about&lt;BR /&gt;read var1 var2 var3 &amp;lt; toptest.txt&lt;BR /&gt;?&lt;BR /&gt;&lt;BR /&gt;greetings,&lt;BR /&gt;&lt;BR /&gt;Michael&lt;BR /&gt;</description>
      <pubDate>Tue, 21 Dec 2004 09:35:11 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-and-assigning-values-to-multiple-variables/m-p/4876352#M707925</guid>
      <dc:creator>Michael Schulte zur Sur</dc:creator>
      <dc:date>2004-12-21T09:35:11Z</dc:date>
    </item>
    <item>
      <title>Re: Awk and assigning values to multiple variables</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-and-assigning-values-to-multiple-variables/m-p/4876353#M707926</link>
      <description>and you could put them all into an array:&lt;BR /&gt;set -A array $(&lt;YOURFILE&gt;&lt;/YOURFILE&gt;print ${array[0]}</description>
      <pubDate>Tue, 21 Dec 2004 09:40:14 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-and-assigning-values-to-multiple-variables/m-p/4876353#M707926</guid>
      <dc:creator>c_51</dc:creator>
      <dc:date>2004-12-21T09:40:14Z</dc:date>
    </item>
    <item>
      <title>Re: Awk and assigning values to multiple variables</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-and-assigning-values-to-multiple-variables/m-p/4876354#M707927</link>
      <description>and if you don't need your positional variables anymore:&lt;BR /&gt;&lt;BR /&gt;set -- $(yourfile)&lt;BR /&gt;&lt;BR /&gt;print $1 $2&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 21 Dec 2004 09:49:49 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-and-assigning-values-to-multiple-variables/m-p/4876354#M707927</guid>
      <dc:creator>c_51</dc:creator>
      <dc:date>2004-12-21T09:49:49Z</dc:date>
    </item>
    <item>
      <title>Re: Awk and assigning values to multiple variables</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-and-assigning-values-to-multiple-variables/m-p/4876355#M707928</link>
      <description>oops &lt;BR /&gt;&lt;BR /&gt;should have been&lt;BR /&gt;&lt;BR /&gt;set -- $(&lt;YOURFILE&gt;&lt;/YOURFILE&gt;&lt;BR /&gt;print $1 $2 &lt;BR /&gt;&lt;BR /&gt;forgot the &amp;lt; in $(&lt;YOURFILE&gt;&lt;/YOURFILE&gt;</description>
      <pubDate>Tue, 21 Dec 2004 09:52:23 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-and-assigning-values-to-multiple-variables/m-p/4876355#M707928</guid>
      <dc:creator>c_51</dc:creator>
      <dc:date>2004-12-21T09:52:23Z</dc:date>
    </item>
    <item>
      <title>Re: Awk and assigning values to multiple variables</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-and-assigning-values-to-multiple-variables/m-p/4876356#M707929</link>
      <description>I'm going for the&lt;BR /&gt;read var1 var2 var3 &amp;lt; toptest.txt&lt;BR /&gt;method.&lt;BR /&gt;&lt;BR /&gt;Thanks for all the input!!&lt;BR /&gt;&lt;BR /&gt;Scott</description>
      <pubDate>Tue, 21 Dec 2004 10:01:59 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-and-assigning-values-to-multiple-variables/m-p/4876356#M707929</guid>
      <dc:creator>Scott Frye_1</dc:creator>
      <dc:date>2004-12-21T10:01:59Z</dc:date>
    </item>
  </channel>
</rss>

