<?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: getting output using awk in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/getting-output-using-awk/m-p/3166285#M160348</link>
    <description>Are both files large?&lt;BR /&gt;If one is small, it may be possible to fill an array with the values and then process each line of the large file, looking up the value in the array.&lt;BR /&gt;&lt;BR /&gt;If both are large, sort both files on the field they have in common. Then read both files, advancing in a file if the common field is less than the field of the current line of the other file.&lt;BR /&gt;&lt;BR /&gt;This may be tricky in awk.&lt;BR /&gt;&lt;BR /&gt;JP.</description>
    <pubDate>Tue, 20 Jan 2004 07:18:54 GMT</pubDate>
    <dc:creator>Jeroen Peereboom</dc:creator>
    <dc:date>2004-01-20T07:18:54Z</dc:date>
    <item>
      <title>getting output using awk</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/getting-output-using-awk/m-p/3166278#M160341</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;I have an awk script that actually parse the fields in the file but my problem is, I must get/grep the field value in another file.&lt;BR /&gt;My script looks like this:&lt;BR /&gt;&lt;BR /&gt;awk '{FIELD1=$1; FIELD2=$2;&lt;BR /&gt;printf ("%15s %10s", FIELD1, FIELD2)}' FILE1&lt;BR /&gt;&lt;BR /&gt;I wanted to get/grep the FIELD2 from FILE2 in order to get another data from FILE2, how do I get it?</description>
      <pubDate>Fri, 16 Jan 2004 08:08:04 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/getting-output-using-awk/m-p/3166278#M160341</guid>
      <dc:creator>Florinda Adato</dc:creator>
      <dc:date>2004-01-16T08:08:04Z</dc:date>
    </item>
    <item>
      <title>Re: getting output using awk</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/getting-output-using-awk/m-p/3166279#M160342</link>
      <description>Within your  awk script you can also tun a grep command:&lt;BR /&gt;&lt;BR /&gt;s1=sprintf(" grep %s FILE2",FIELD2);&lt;BR /&gt;system(s1);&lt;BR /&gt;&lt;BR /&gt;Note for each FIELD2 it will generate a process grep &lt;FILED2&gt; FILE2.&lt;BR /&gt;&lt;BR /&gt;Rgds,&lt;BR /&gt;Jean-Luc&lt;/FILED2&gt;</description>
      <pubDate>Fri, 16 Jan 2004 08:37:40 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/getting-output-using-awk/m-p/3166279#M160342</guid>
      <dc:creator>Jean-Luc Oudart</dc:creator>
      <dc:date>2004-01-16T08:37:40Z</dc:date>
    </item>
    <item>
      <title>Re: getting output using awk</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/getting-output-using-awk/m-p/3166280#M160343</link>
      <description>Thanks. But how will I save the output of my grep to another variable?</description>
      <pubDate>Fri, 16 Jan 2004 08:54:52 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/getting-output-using-awk/m-p/3166280#M160343</guid>
      <dc:creator>Florinda Adato</dc:creator>
      <dc:date>2004-01-16T08:54:52Z</dc:date>
    </item>
    <item>
      <title>Re: getting output using awk</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/getting-output-using-awk/m-p/3166281#M160344</link>
      <description>How about using "join" to combine the fields you want from file1 and file2.&lt;BR /&gt; &lt;BR /&gt;Example-&lt;BR /&gt;join -j1 1 -j2 1 -o 1.1,2.2 | awk ...&lt;BR /&gt; &lt;BR /&gt;This would send the common key field for file1 and file2 and the second field of file2 to awk.&lt;BR /&gt; &lt;BR /&gt;"join" works like a SQL join, treating the 2 text files like tables.&lt;BR /&gt; &lt;BR /&gt;HTH&lt;BR /&gt; &lt;BR /&gt;-- Rod Hills</description>
      <pubDate>Fri, 16 Jan 2004 10:45:44 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/getting-output-using-awk/m-p/3166281#M160344</guid>
      <dc:creator>Rodney Hills</dc:creator>
      <dc:date>2004-01-16T10:45:44Z</dc:date>
    </item>
    <item>
      <title>Re: getting output using awk</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/getting-output-using-awk/m-p/3166282#M160345</link>
      <description>Thanks.&lt;BR /&gt;&lt;BR /&gt;Join works fine but I need find the matched&lt;BR /&gt;of field2 from file2 using awk.&lt;BR /&gt;&lt;BR /&gt;My FILE1 have these fields:&lt;BR /&gt;12345 20&lt;BR /&gt;12346 30&lt;BR /&gt;&lt;BR /&gt;My FILE2 have these fields:&lt;BR /&gt;20 hello&lt;BR /&gt;30 thanks&lt;BR /&gt;&lt;BR /&gt;What I want is to get the string "hello" or "thanks" in my awk.&lt;BR /&gt;&lt;BR /&gt;The output will be something like these:&lt;BR /&gt;12345 20 hello&lt;BR /&gt;12346 30 thanks&lt;BR /&gt;</description>
      <pubDate>Tue, 20 Jan 2004 03:47:14 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/getting-output-using-awk/m-p/3166282#M160345</guid>
      <dc:creator>Florinda Adato</dc:creator>
      <dc:date>2004-01-20T03:47:14Z</dc:date>
    </item>
    <item>
      <title>Re: getting output using awk</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/getting-output-using-awk/m-p/3166283#M160346</link>
      <description>try this one(if the files are very big it will take a while because it running through file1 for each entry in file2:&lt;BR /&gt;&lt;BR /&gt;cat file2 | while read indx word&lt;BR /&gt;do&lt;BR /&gt;indx2=""&lt;BR /&gt; cat file1 | while read field1 indx2&lt;BR /&gt; do&lt;BR /&gt; if [ $indx -eq $indx2 ]&lt;BR /&gt; then &lt;BR /&gt; echo "$field1 $indx $word"&lt;BR /&gt; fi&lt;BR /&gt; done&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;file1:&lt;BR /&gt;12345 20&lt;BR /&gt;12346 30&lt;BR /&gt;&lt;BR /&gt;file2&lt;BR /&gt;20 hello&lt;BR /&gt;30 thanks&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Output:&lt;BR /&gt;12345 20 hello&lt;BR /&gt;12346 30 thanks&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;&lt;BR /&gt;Peter</description>
      <pubDate>Tue, 20 Jan 2004 04:22:54 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/getting-output-using-awk/m-p/3166283#M160346</guid>
      <dc:creator>Hoefnix</dc:creator>
      <dc:date>2004-01-20T04:22:54Z</dc:date>
    </item>
    <item>
      <title>Re: getting output using awk</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/getting-output-using-awk/m-p/3166284#M160347</link>
      <description>My file is about 700k lines, I need something faster.</description>
      <pubDate>Tue, 20 Jan 2004 04:27:20 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/getting-output-using-awk/m-p/3166284#M160347</guid>
      <dc:creator>Florinda Adato</dc:creator>
      <dc:date>2004-01-20T04:27:20Z</dc:date>
    </item>
    <item>
      <title>Re: getting output using awk</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/getting-output-using-awk/m-p/3166285#M160348</link>
      <description>Are both files large?&lt;BR /&gt;If one is small, it may be possible to fill an array with the values and then process each line of the large file, looking up the value in the array.&lt;BR /&gt;&lt;BR /&gt;If both are large, sort both files on the field they have in common. Then read both files, advancing in a file if the common field is less than the field of the current line of the other file.&lt;BR /&gt;&lt;BR /&gt;This may be tricky in awk.&lt;BR /&gt;&lt;BR /&gt;JP.</description>
      <pubDate>Tue, 20 Jan 2004 07:18:54 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/getting-output-using-awk/m-p/3166285#M160348</guid>
      <dc:creator>Jeroen Peereboom</dc:creator>
      <dc:date>2004-01-20T07:18:54Z</dc:date>
    </item>
    <item>
      <title>Re: getting output using awk</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/getting-output-using-awk/m-p/3166286#M160349</link>
      <description>(&lt;BR /&gt;   cat FILE2&lt;BR /&gt;   echo --- starting data ---&lt;BR /&gt;   cat FILE1&lt;BR /&gt;) awk '/--- starting data ---/ {infile1=1}&lt;BR /&gt;infile1==0 { response[$1]=$2 }&lt;BR /&gt;infile1==1 { printf("%15s %10s %s\n",$1,$2,response[$2]);}'&lt;BR /&gt;&lt;BR /&gt;This should do the trick...</description>
      <pubDate>Tue, 20 Jan 2004 09:16:01 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/getting-output-using-awk/m-p/3166286#M160349</guid>
      <dc:creator>Elmar P. Kolkman</dc:creator>
      <dc:date>2004-01-20T09:16:01Z</dc:date>
    </item>
    <item>
      <title>Re: getting output using awk</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/getting-output-using-awk/m-p/3166287#M160350</link>
      <description>Elamr,&lt;BR /&gt;&lt;BR /&gt;looks nice. Wonder what Florinda thinks (and awards?)&lt;BR /&gt;&lt;BR /&gt;JP.</description>
      <pubDate>Tue, 20 Jan 2004 13:44:24 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/getting-output-using-awk/m-p/3166287#M160350</guid>
      <dc:creator>Jeroen Peereboom</dc:creator>
      <dc:date>2004-01-20T13:44:24Z</dc:date>
    </item>
    <item>
      <title>Re: getting output using awk</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/getting-output-using-awk/m-p/3166288#M160351</link>
      <description>Jeroen, Nice to see you online... ;-) Long time no see. While I'm back at the company we worked together in the past...&lt;BR /&gt;&lt;BR /&gt;Florinda, if you check my solutions, put a pipe ('|') between the closing bracket ('}') and awk, otherwise it won't work (and complain about a syntax error).</description>
      <pubDate>Wed, 21 Jan 2004 01:20:10 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/getting-output-using-awk/m-p/3166288#M160351</guid>
      <dc:creator>Elmar P. Kolkman</dc:creator>
      <dc:date>2004-01-21T01:20:10Z</dc:date>
    </item>
    <item>
      <title>Re: getting output using awk</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/getting-output-using-awk/m-p/3166289#M160352</link>
      <description>thank you very much, until next time :-)</description>
      <pubDate>Wed, 21 Jan 2004 03:31:52 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/getting-output-using-awk/m-p/3166289#M160352</guid>
      <dc:creator>Florinda Adato</dc:creator>
      <dc:date>2004-01-21T03:31:52Z</dc:date>
    </item>
    <item>
      <title>Re: getting output using awk</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/getting-output-using-awk/m-p/3166290#M160353</link>
      <description>Hello.&lt;BR /&gt;&lt;BR /&gt;How about if my files are something like these: &lt;BR /&gt;&lt;BR /&gt;::::::::::::::&lt;BR /&gt;FILE1&lt;BR /&gt;::::::::::::::&lt;BR /&gt;12345 123 123 20&lt;BR /&gt;12346 123 123 30&lt;BR /&gt;12347 123 123 20&lt;BR /&gt;12348 123 123 90&lt;BR /&gt;::::::::::::::&lt;BR /&gt;FILE2&lt;BR /&gt;::::::::::::::&lt;BR /&gt;20 hello&lt;BR /&gt;30 thanks&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;OUTPUT IS:&lt;BR /&gt;12345 123 123 20 hello&lt;BR /&gt;12346 123 123 30 thanks&lt;BR /&gt;12347 123 123 20 hello&lt;BR /&gt;12348 123 123 90&lt;BR /&gt;&lt;BR /&gt;Sorry I'm very new in using awk.&lt;BR /&gt;&lt;BR /&gt;Thanks</description>
      <pubDate>Wed, 21 Jan 2004 05:08:12 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/getting-output-using-awk/m-p/3166290#M160353</guid>
      <dc:creator>Florinda Adato</dc:creator>
      <dc:date>2004-01-21T05:08:12Z</dc:date>
    </item>
    <item>
      <title>Re: getting output using awk</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/getting-output-using-awk/m-p/3166291#M160354</link>
      <description>You can use the same script I sent earlier, but replace the line &lt;BR /&gt;'infile1==1 { printf("%15s %10s %s\n",$1,$2,response[$2]);}'&lt;BR /&gt;&lt;BR /&gt;with&lt;BR /&gt;&lt;BR /&gt;'infile1==1 { printf("%s %s\n",$0,response[$NF]);}'&lt;BR /&gt;&lt;BR /&gt;This will work, no matter how many fields are in FILE1</description>
      <pubDate>Wed, 21 Jan 2004 05:28:32 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/getting-output-using-awk/m-p/3166291#M160354</guid>
      <dc:creator>Elmar P. Kolkman</dc:creator>
      <dc:date>2004-01-21T05:28:32Z</dc:date>
    </item>
    <item>
      <title>Re: getting output using awk</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/getting-output-using-awk/m-p/3166292#M160355</link>
      <description>The same in perl, and it's probably faster.&lt;BR /&gt;&lt;BR /&gt;#!/usr/contrib/bin/perl&lt;BR /&gt;&lt;BR /&gt;open(FILE2, $ARGV[1]);&lt;BR /&gt;while(&lt;FILE2&gt;) {&lt;BR /&gt;        ($field1, $field2)=split;&lt;BR /&gt;        $map{$field1}=$field2;&lt;BR /&gt;}&lt;BR /&gt;close(FILE2);&lt;BR /&gt;&lt;BR /&gt;open(FILE1, $ARGV[0]);&lt;BR /&gt;while(&lt;FILE1&gt;) {&lt;BR /&gt;        chop;&lt;BR /&gt;        @l=split;&lt;BR /&gt;        print "$_ $map{$l[$#l]}\n";&lt;BR /&gt;}&lt;BR /&gt;close(FILE1);&lt;BR /&gt;&lt;/FILE1&gt;&lt;/FILE2&gt;</description>
      <pubDate>Wed, 21 Jan 2004 06:10:23 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/getting-output-using-awk/m-p/3166292#M160355</guid>
      <dc:creator>Marc Roger</dc:creator>
      <dc:date>2004-01-21T06:10:23Z</dc:date>
    </item>
  </channel>
</rss>

