<?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: multiple variable search in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/multiple-variable-search/m-p/3129164#M152647</link>
    <description>The greps can be consolidated into one egrep:&lt;BR /&gt;egrep "${num1}.*${num2}|${num2}.*${num1}"&lt;BR /&gt;&lt;BR /&gt;Or if the file is comma seperated:&lt;BR /&gt;egrep "${num1},${num2}|${num2},${num1}"</description>
    <pubDate>Wed, 26 Nov 2003 09:36:14 GMT</pubDate>
    <dc:creator>Elmar P. Kolkman</dc:creator>
    <dc:date>2003-11-26T09:36:14Z</dc:date>
    <item>
      <title>multiple variable search</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/multiple-variable-search/m-p/3129156#M152639</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;we have a file with x amount of lines, on each line are numbers(ie. 1234 7896) and we need to search through all occurrences &lt;BR /&gt;of when these 2 numbers appear? So both numbers MUST appear in each record. Our script can only read one variable/number&lt;BR /&gt;and not both. Does anyone know how we could read 2 variables into a file search?&lt;BR /&gt;&lt;BR /&gt;cat numbers.list | while read num1 num2&lt;BR /&gt;&lt;BR /&gt;do&lt;BR /&gt;&lt;BR /&gt;gzcat filename*.gz | grep $num1 &amp;gt; data_extract.log&lt;BR /&gt;&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;Thanks!</description>
      <pubDate>Wed, 26 Nov 2003 07:13:09 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/multiple-variable-search/m-p/3129156#M152639</guid>
      <dc:creator>Edgar_8</dc:creator>
      <dc:date>2003-11-26T07:13:09Z</dc:date>
    </item>
    <item>
      <title>Re: multiple variable search</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/multiple-variable-search/m-p/3129157#M152640</link>
      <description>Hi,&lt;BR /&gt;a bit primitive, change the line:&lt;BR /&gt;gzcat filename*.gz | grep $num1 &amp;gt; data_extract.log&lt;BR /&gt;to&lt;BR /&gt;gzcat filename*.gz | grep "$num1" | grep "$num2" &amp;gt; data_extractlog&lt;BR /&gt; &lt;BR /&gt;regards,&lt;BR /&gt;John K.&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Wed, 26 Nov 2003 07:25:47 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/multiple-variable-search/m-p/3129157#M152640</guid>
      <dc:creator>john korterman</dc:creator>
      <dc:date>2003-11-26T07:25:47Z</dc:date>
    </item>
    <item>
      <title>Re: multiple variable search</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/multiple-variable-search/m-p/3129158#M152641</link>
      <description>&lt;BR /&gt;grep -i "1234" input_file &amp;gt; /tmp/file.txt&lt;BR /&gt;grep -i "7896"  input_file &amp;gt;&amp;gt; /tmp/file.txt&lt;BR /&gt;&lt;BR /&gt;for i in `cat  /tmp/file.txt`&lt;BR /&gt;do&lt;BR /&gt;echo $i|grep "1234"|grep "7896"&lt;BR /&gt;if  [ $? -eq 0]&lt;BR /&gt;then&lt;BR /&gt;echo $i &amp;gt; /tmp/final.txt&lt;BR /&gt;exit&lt;BR /&gt;</description>
      <pubDate>Wed, 26 Nov 2003 07:29:18 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/multiple-variable-search/m-p/3129158#M152641</guid>
      <dc:creator>RAC_1</dc:creator>
      <dc:date>2003-11-26T07:29:18Z</dc:date>
    </item>
    <item>
      <title>Re: multiple variable search</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/multiple-variable-search/m-p/3129159#M152642</link>
      <description>OR the onliner&lt;BR /&gt;&lt;BR /&gt;cat input_file|grep -i "1234"|grep -i "7896"</description>
      <pubDate>Wed, 26 Nov 2003 07:31:17 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/multiple-variable-search/m-p/3129159#M152642</guid>
      <dc:creator>RAC_1</dc:creator>
      <dc:date>2003-11-26T07:31:17Z</dc:date>
    </item>
    <item>
      <title>Re: multiple variable search</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/multiple-variable-search/m-p/3129160#M152643</link>
      <description>perhaps you can be a little nore specific as to why it did not work out. Are you looking for exact matches with spaces on each side of the numbers or?&lt;BR /&gt; &lt;BR /&gt;regards,&lt;BR /&gt;John K.</description>
      <pubDate>Wed, 26 Nov 2003 08:57:46 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/multiple-variable-search/m-p/3129160#M152643</guid>
      <dc:creator>john korterman</dc:creator>
      <dc:date>2003-11-26T08:57:46Z</dc:date>
    </item>
    <item>
      <title>Re: multiple variable search</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/multiple-variable-search/m-p/3129161#M152644</link>
      <description>For efficiency, I suggest that you gunzip the file that you are searching once only to a temporary file (provided space is not an issue).&lt;BR /&gt;&lt;BR /&gt;Something like:&lt;BR /&gt;&lt;BR /&gt;TMPF=/tmp/whatever.${$}&lt;BR /&gt;rm -f data_extract.log&lt;BR /&gt;&lt;BR /&gt;gzcat filename &amp;gt; ${TMPF}&lt;BR /&gt;&lt;BR /&gt;cat numbers.list | {&lt;BR /&gt;while read num1 num2&lt;BR /&gt;do&lt;BR /&gt; grep "${num1}.*${num2}" ${TMPF} &amp;gt;&amp;gt; data_extract.log&lt;BR /&gt;done&lt;BR /&gt;}&lt;BR /&gt;rm ${TMPF}&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;John&lt;BR /&gt;</description>
      <pubDate>Wed, 26 Nov 2003 09:13:30 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/multiple-variable-search/m-p/3129161#M152644</guid>
      <dc:creator>John Palmer</dc:creator>
      <dc:date>2003-11-26T09:13:30Z</dc:date>
    </item>
    <item>
      <title>Re: multiple variable search</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/multiple-variable-search/m-p/3129162#M152645</link>
      <description>Hi John,&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;We have an input file (input.lst) containing numbers &amp;amp; we have approx. 200 comma separated files.What we want to do &lt;BR /&gt;is search for the occurence of each number in the input file in the comma separated file &amp;amp; extract the entire record.&lt;BR /&gt;The input file looks like:&lt;BR /&gt;&lt;BR /&gt;12345,6789&lt;BR /&gt;43212,09878&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;6543218,4253759&lt;BR /&gt;&lt;BR /&gt;etc. Any ideas how this extract could be achieved?&lt;BR /&gt;</description>
      <pubDate>Wed, 26 Nov 2003 09:19:46 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/multiple-variable-search/m-p/3129162#M152645</guid>
      <dc:creator>Edgar_8</dc:creator>
      <dc:date>2003-11-26T09:19:46Z</dc:date>
    </item>
    <item>
      <title>Re: multiple variable search</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/multiple-variable-search/m-p/3129163#M152646</link>
      <description>If the numbers you want to read are seperated by a comma then do this&lt;BR /&gt;&lt;BR /&gt;IFS=,&lt;BR /&gt;cat input.lst | {&lt;BR /&gt;while read num1 num2&lt;BR /&gt;...&lt;BR /&gt;&lt;BR /&gt;Need some more info and examples of what you want to do though.</description>
      <pubDate>Wed, 26 Nov 2003 09:33:51 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/multiple-variable-search/m-p/3129163#M152646</guid>
      <dc:creator>John Palmer</dc:creator>
      <dc:date>2003-11-26T09:33:51Z</dc:date>
    </item>
    <item>
      <title>Re: multiple variable search</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/multiple-variable-search/m-p/3129164#M152647</link>
      <description>The greps can be consolidated into one egrep:&lt;BR /&gt;egrep "${num1}.*${num2}|${num2}.*${num1}"&lt;BR /&gt;&lt;BR /&gt;Or if the file is comma seperated:&lt;BR /&gt;egrep "${num1},${num2}|${num2},${num1}"</description>
      <pubDate>Wed, 26 Nov 2003 09:36:14 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/multiple-variable-search/m-p/3129164#M152647</guid>
      <dc:creator>Elmar P. Kolkman</dc:creator>
      <dc:date>2003-11-26T09:36:14Z</dc:date>
    </item>
    <item>
      <title>Re: multiple variable search</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/multiple-variable-search/m-p/3129165#M152648</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;try this&lt;BR /&gt;&lt;BR /&gt;cat numbers.list | while read num1 num2&lt;BR /&gt;&lt;BR /&gt;do&lt;BR /&gt;&lt;BR /&gt;gzcat filename*.gz | grep -E ".*$num1.*$num2|.*$num2.*$num1" &amp;gt; data_extract.log&lt;BR /&gt;&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;greetings,&lt;BR /&gt;&lt;BR /&gt;Michael&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Wed, 26 Nov 2003 09:54:17 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/multiple-variable-search/m-p/3129165#M152648</guid>
      <dc:creator>Michael Schulte zur Sur</dc:creator>
      <dc:date>2003-11-26T09:54:17Z</dc:date>
    </item>
    <item>
      <title>Re: multiple variable search</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/multiple-variable-search/m-p/3129166#M152649</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;in case the numbers are as show, you can use&lt;BR /&gt;&lt;BR /&gt;gzcat filename*.gz | grep -E ".*$num1,$num2|.*$num2,$num1" &amp;gt; data_extract.log&lt;BR /&gt;&lt;BR /&gt;greetings,&lt;BR /&gt;&lt;BR /&gt;Michael&lt;BR /&gt;</description>
      <pubDate>Wed, 26 Nov 2003 09:56:12 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/multiple-variable-search/m-p/3129166#M152649</guid>
      <dc:creator>Michael Schulte zur Sur</dc:creator>
      <dc:date>2003-11-26T09:56:12Z</dc:date>
    </item>
    <item>
      <title>Re: multiple variable search</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/multiple-variable-search/m-p/3129167#M152650</link>
      <description>&lt;BR /&gt;Edgar&lt;BR /&gt;&lt;BR /&gt;Not sure if I've understood. &lt;BR /&gt;My solution looks nothing like any other, so probably not.&lt;BR /&gt;&lt;BR /&gt;In your initial post you are looking for pairs of numbers, later you talk about them coming from input.lst&lt;BR /&gt;&lt;BR /&gt;I would try awk, using the BEGIN clause to read in your numbers file, then processing all other files, comparing against the lists.&lt;BR /&gt;&lt;BR /&gt;It is horribly inefficient.&lt;BR /&gt;&lt;BR /&gt;Create a file, say edgar.awk, containing&lt;BR /&gt;--&lt;BR /&gt;BEGIN { &lt;BR /&gt;  pairs=0&lt;BR /&gt;  do {&lt;BR /&gt;    eof = getline &amp;lt; "input.lst"&lt;BR /&gt;    if (eof == 1) {&lt;BR /&gt;      n=split ($0,pair,",")&lt;BR /&gt;      if (n==2) {&lt;BR /&gt;        pairs++&lt;BR /&gt;        number1 [pairs]=pair[1]&lt;BR /&gt;        number2 [pairs]=pair[2]&lt;BR /&gt;      }&lt;BR /&gt;    }&lt;BR /&gt;  } while (eof == 1)&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;{ &lt;BR /&gt;  for (i=1;i&amp;lt;=pairs;i++) {&lt;BR /&gt;    if (($0 ~ number1[$i]) &amp;amp;&amp;amp; ($0 ~ number2[$i])) {&lt;BR /&gt;      print&lt;BR /&gt;      next&lt;BR /&gt;    }&lt;BR /&gt;  }&lt;BR /&gt;}&lt;BR /&gt;--&lt;BR /&gt;&lt;BR /&gt;and invoke with awk -f edgar.awk *.csv (where *.csv represents your comma separated files.&lt;BR /&gt;&lt;BR /&gt;I think from your earlier example that this might be&lt;BR /&gt;gzcat filename*.gz  | awk -f edgar.awk  &lt;BR /&gt;&lt;BR /&gt;-- Graham</description>
      <pubDate>Wed, 26 Nov 2003 10:27:45 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/multiple-variable-search/m-p/3129167#M152650</guid>
      <dc:creator>Graham Cameron_1</dc:creator>
      <dc:date>2003-11-26T10:27:45Z</dc:date>
    </item>
    <item>
      <title>Re: multiple variable search</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/multiple-variable-search/m-p/3129168#M152651</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;if the problem is solved, could you spare some points from the endless supply of points, HP has, for those, who could help you? ;-)&lt;BR /&gt;&lt;BR /&gt;greetings,&lt;BR /&gt;&lt;BR /&gt;Michael</description>
      <pubDate>Thu, 27 Nov 2003 08:21:46 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/multiple-variable-search/m-p/3129168#M152651</guid>
      <dc:creator>Michael Schulte zur Sur</dc:creator>
      <dc:date>2003-11-27T08:21:46Z</dc:date>
    </item>
  </channel>
</rss>

