<?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: Grep in AWK in Operating System - Linux</title>
    <link>https://community.hpe.com/t5/operating-system-linux/grep-in-awk/m-p/2491743#M98219</link>
    <description>Hi Praveen,&lt;BR /&gt;The same problem I am also encountered.&lt;BR /&gt;And I am also searching for the same solution.&lt;BR /&gt;the last solution you got seem to be a good one but it is not working for me and I could not able to understand &lt;BR /&gt;f1[ii] = $NF&lt;BR /&gt;If something worked for you then kindly post it to me.&lt;BR /&gt;Thanks advanced,&lt;BR /&gt;Regards,&lt;BR /&gt;Anantha Ganiga</description>
    <pubDate>Fri, 11 Aug 2006 03:04:24 GMT</pubDate>
    <dc:creator>Anantha Ganiga</dc:creator>
    <dc:date>2006-08-11T03:04:24Z</dc:date>
    <item>
      <title>Grep in AWK</title>
      <link>https://community.hpe.com/t5/operating-system-linux/grep-in-awk/m-p/2491733#M98209</link>
      <description>Hi&lt;BR /&gt;  Can we use grep inside an awk statement ?&lt;BR /&gt;Praveen</description>
      <pubDate>Fri, 09 Feb 2001 08:56:23 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/grep-in-awk/m-p/2491733#M98209</guid>
      <dc:creator>Praveen Bezawada</dc:creator>
      <dc:date>2001-02-09T08:56:23Z</dc:date>
    </item>
    <item>
      <title>Re: Grep in AWK</title>
      <link>https://community.hpe.com/t5/operating-system-linux/grep-in-awk/m-p/2491734#M98210</link>
      <description>Hi !&lt;BR /&gt;&lt;BR /&gt;Insite awk You can call system() function. In system You can run grep.&lt;BR /&gt;I'm not sure it good for You .&lt;BR /&gt;&lt;BR /&gt;Why do You want to do ?&lt;BR /&gt;&lt;BR /&gt;regards, Saa</description>
      <pubDate>Fri, 09 Feb 2001 09:10:22 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/grep-in-awk/m-p/2491734#M98210</guid>
      <dc:creator>Sandor Horvath_2</dc:creator>
      <dc:date>2001-02-09T09:10:22Z</dc:date>
    </item>
    <item>
      <title>Re: Grep in AWK</title>
      <link>https://community.hpe.com/t5/operating-system-linux/grep-in-awk/m-p/2491735#M98211</link>
      <description>Hi Praveen,&lt;BR /&gt;&lt;BR /&gt;AWK has a very useful string search feature which could possibly make the use of external programs like grep useless.&lt;BR /&gt;&lt;BR /&gt;If you want to use grep anyway, you can do it through the use of the system(cmd) call.&lt;BR /&gt;&lt;BR /&gt;Best regards,&lt;BR /&gt;&lt;BR /&gt;Dan&lt;BR /&gt;</description>
      <pubDate>Fri, 09 Feb 2001 09:19:33 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/grep-in-awk/m-p/2491735#M98211</guid>
      <dc:creator>Dan Hetzel</dc:creator>
      <dc:date>2001-02-09T09:19:33Z</dc:date>
    </item>
    <item>
      <title>Re: Grep in AWK</title>
      <link>https://community.hpe.com/t5/operating-system-linux/grep-in-awk/m-p/2491736#M98212</link>
      <description>I need to read lines in one file and for some particular fields in that line check if they are present in a songle line of another file.&lt;BR /&gt;&lt;BR /&gt;  So I want to awk the first file , get the fields and grep in the second file.</description>
      <pubDate>Fri, 09 Feb 2001 09:20:13 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/grep-in-awk/m-p/2491736#M98212</guid>
      <dc:creator>Praveen Bezawada</dc:creator>
      <dc:date>2001-02-09T09:20:13Z</dc:date>
    </item>
    <item>
      <title>Re: Grep in AWK</title>
      <link>https://community.hpe.com/t5/operating-system-linux/grep-in-awk/m-p/2491737#M98213</link>
      <description>Praveen,&lt;BR /&gt;&lt;BR /&gt;You can use regular expressions in awk statements (instead of calling grep thru a 'system' call), like in this example:&lt;BR /&gt;&lt;BR /&gt;$ echo "hello world" | awk '$1 ~ /[Hh]ello/ '{print $1}'&lt;BR /&gt;hello&lt;BR /&gt;&lt;BR /&gt;knowing that $0 represents the entire string "hello world", which can be separated into multiple substrings (hello=$1, world=$2). Substrings are determined by delimiter specified by the -F flag of awk (space by default).&lt;BR /&gt;&lt;BR /&gt;--&lt;BR /&gt;&lt;BR /&gt;To retrieve each line of an input file, and do some processing afterwards (by splitting lines into multiple fields according to some patterns), you could issue:&lt;BR /&gt;&lt;BR /&gt; # do some processing&lt;BR /&gt;&lt;BR /&gt;cat myfile | awk 'BEGIN { while (getline) {&lt;BR /&gt;   print $0&lt;BR /&gt;   # do some further processing, knowing that each line is stored in $0&lt;BR /&gt;   } # end while&lt;BR /&gt;  }'&lt;BR /&gt;&lt;BR /&gt;If you are used to Perl, then awk should'nt be a pb for you.&lt;BR /&gt;&lt;BR /&gt;I would recommend the "sed &amp;amp; awk" book, from Dale Dougherty &amp;amp; Arnold Robbins, published by O'Reilly (ISBN 1-56592-225-5), which will show you all the powerful features of awk.&lt;BR /&gt;&lt;BR /&gt;I hope this helps.&lt;BR /&gt;&lt;BR /&gt;Bests,&lt;BR /&gt;&lt;BR /&gt;Fred.</description>
      <pubDate>Fri, 09 Feb 2001 09:35:07 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/grep-in-awk/m-p/2491737#M98213</guid>
      <dc:creator>Frederic Soriano</dc:creator>
      <dc:date>2001-02-09T09:35:07Z</dc:date>
    </item>
    <item>
      <title>Re: Grep in AWK</title>
      <link>https://community.hpe.com/t5/operating-system-linux/grep-in-awk/m-p/2491738#M98214</link>
      <description>I can get the individual fields but after that I need to search for them in another file.&lt;BR /&gt;   So I need to use something similar to grep. isn't it ???</description>
      <pubDate>Fri, 09 Feb 2001 09:37:08 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/grep-in-awk/m-p/2491738#M98214</guid>
      <dc:creator>Praveen Bezawada</dc:creator>
      <dc:date>2001-02-09T09:37:08Z</dc:date>
    </item>
    <item>
      <title>Re: Grep in AWK</title>
      <link>https://community.hpe.com/t5/operating-system-linux/grep-in-awk/m-p/2491739#M98215</link>
      <description>Hi again,&lt;BR /&gt;&lt;BR /&gt;What you could do is something like that:&lt;BR /&gt;&lt;BR /&gt;cat myfile | awk 'BEGIN { while (getline) { &lt;BR /&gt;                                     print $0 &lt;BR /&gt;                                     # do some further processing, knowing that each line is stored&lt;BR /&gt;                                     in $0 &lt;BR /&gt;                                     } # end while &lt;BR /&gt;                                     }' | while read myvar&lt;BR /&gt;do&lt;BR /&gt;grep $myvar file2&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;This is quick and dirty, but this should do the trick.&lt;BR /&gt;&lt;BR /&gt;Bests !&lt;BR /&gt;&lt;BR /&gt;Fred.</description>
      <pubDate>Fri, 09 Feb 2001 09:41:38 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/grep-in-awk/m-p/2491739#M98215</guid>
      <dc:creator>Frederic Soriano</dc:creator>
      <dc:date>2001-02-09T09:41:38Z</dc:date>
    </item>
    <item>
      <title>Re: Grep in AWK</title>
      <link>https://community.hpe.com/t5/operating-system-linux/grep-in-awk/m-p/2491740#M98216</link>
      <description>Can I have the syntax of using system in awk</description>
      <pubDate>Fri, 09 Feb 2001 10:00:58 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/grep-in-awk/m-p/2491740#M98216</guid>
      <dc:creator>Praveen Bezawada</dc:creator>
      <dc:date>2001-02-09T10:00:58Z</dc:date>
    </item>
    <item>
      <title>Re: Grep in AWK</title>
      <link>https://community.hpe.com/t5/operating-system-linux/grep-in-awk/m-p/2491741#M98217</link>
      <description>Praveen,&lt;BR /&gt;&lt;BR /&gt;It's as Dan and Saandor told you:&lt;BR /&gt;system(cmd)&lt;BR /&gt;eg:&lt;BR /&gt;system ("mkdir test")&lt;BR /&gt;&lt;BR /&gt;But be warned that the system function, as implemented in awk, does not make the output of the command available within the program for processing. " It returns the exit status of the command that was executed. The script waits for the command to finish before continuing execution". (excerpt of "sed &amp;amp; awk" book)&lt;BR /&gt;&lt;BR /&gt;Hope this helps.&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;&lt;BR /&gt;Fred.</description>
      <pubDate>Fri, 09 Feb 2001 10:21:02 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/grep-in-awk/m-p/2491741#M98217</guid>
      <dc:creator>Frederic Soriano</dc:creator>
      <dc:date>2001-02-09T10:21:02Z</dc:date>
    </item>
    <item>
      <title>Re: Grep in AWK</title>
      <link>https://community.hpe.com/t5/operating-system-linux/grep-in-awk/m-p/2491742#M98218</link>
      <description>Ok, we will tell you.&lt;BR /&gt;&lt;BR /&gt;#files a:&lt;BR /&gt;#-rwxr-xr-x   1 root       sys            252 Dec 18 09:23 mboxhwint.sh&lt;BR /&gt;#drwxr-xr-x   2 root       sys             96 Mar 31  1998 meminfo&lt;BR /&gt;#-rwxr-xr-x   1 root       sys            238 Aug 10  2000 mkhwtext.sh&lt;BR /&gt;#-rw-------   1 root       sys           1331 Dec 28 13:11 nohup.out&lt;BR /&gt;#-rwxr-xr-x   1 root       sys             80 Aug 14 10:47 pp.bat&lt;BR /&gt;#-rw-r--r--   1 root       sys           4311 Dec  6  1999 swlist.txt&lt;BR /&gt;#drwxr-xr-x   3 root       sys             96 Aug 25  1998 tscript&lt;BR /&gt;#-rw-rw-rw-   1 root       sys            569 Nov 11  1999 whichchar.c&lt;BR /&gt;#&lt;BR /&gt;#file b:&lt;BR /&gt;#drwxr-xr-x   2 root       sys             96 Mar 31  1998 meminfo&lt;BR /&gt;#drwxr-xr-x   3 root       sys           2048 Jan 25 10:22 script&lt;BR /&gt;#dr-xr-xr-x   2 root       sys           1024 Oct 10  1997 script.old&lt;BR /&gt;#drwxr-xr-x   3 root       sys             96 Aug 25  1998 tscript&lt;BR /&gt;#&lt;BR /&gt;#&lt;BR /&gt;#Result:&lt;BR /&gt;#drwxr-xr-x   2 root       sys             96 Mar 31  1998 meminfo&lt;BR /&gt;#drwxr-xr-x   3 root       sys             96 Aug 25  1998 tscript&lt;BR /&gt; &lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;awk 'BEGIN{ while (getline &amp;lt; "b"){&lt;BR /&gt;    ii++&lt;BR /&gt;    patt=tolower( $NF)&lt;BR /&gt;    f1[ii] = $NF&lt;BR /&gt;    }&lt;BR /&gt;}&lt;BR /&gt;{&lt;BR /&gt;line=tolower( $0)&lt;BR /&gt;for( jj = i; jj &amp;lt;= ii; jj++) if( index( $0, f1[ jj])) {print $0; next}&lt;BR /&gt;}' a&lt;BR /&gt;&lt;BR /&gt;succes</description>
      <pubDate>Mon, 12 Feb 2001 10:10:14 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/grep-in-awk/m-p/2491742#M98218</guid>
      <dc:creator>Gregor Weertman</dc:creator>
      <dc:date>2001-02-12T10:10:14Z</dc:date>
    </item>
    <item>
      <title>Re: Grep in AWK</title>
      <link>https://community.hpe.com/t5/operating-system-linux/grep-in-awk/m-p/2491743#M98219</link>
      <description>Hi Praveen,&lt;BR /&gt;The same problem I am also encountered.&lt;BR /&gt;And I am also searching for the same solution.&lt;BR /&gt;the last solution you got seem to be a good one but it is not working for me and I could not able to understand &lt;BR /&gt;f1[ii] = $NF&lt;BR /&gt;If something worked for you then kindly post it to me.&lt;BR /&gt;Thanks advanced,&lt;BR /&gt;Regards,&lt;BR /&gt;Anantha Ganiga</description>
      <pubDate>Fri, 11 Aug 2006 03:04:24 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/grep-in-awk/m-p/2491743#M98219</guid>
      <dc:creator>Anantha Ganiga</dc:creator>
      <dc:date>2006-08-11T03:04:24Z</dc:date>
    </item>
    <item>
      <title>Re: Grep in AWK</title>
      <link>https://community.hpe.com/t5/operating-system-linux/grep-in-awk/m-p/2491744#M98220</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;the assignment of the arry elements should read as&lt;BR /&gt;f1[ii] = $NF&lt;BR /&gt;&lt;BR /&gt;The whole script I would change to&lt;BR /&gt;- a pure awk script&lt;BR /&gt;- not ignoring case sensivity&lt;BR /&gt;- include some flexibility&lt;BR /&gt;&lt;BR /&gt;file get_bs_of_a.awk:&lt;BR /&gt;#!/usr/bin/awk&lt;BR /&gt;BEGIN{ while (getline &amp;lt; "b") f1[++ii] = $NF} &lt;BR /&gt;found_in_a { mypatt=$0&lt;BR /&gt;for( j=1; jj &amp;lt;=ii; jj++) if(index(mypatt, f1[jj]) {print "in a: "$0,"in b: "f1[j]"}&lt;BR /&gt;&lt;BR /&gt;execute as&lt;BR /&gt;get_bs_of_a.awk  a&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;What is done:&lt;BR /&gt;In the BEGIN statement you once collect the content of file "b" in an array - i.e. the file you lookup for matching pattern of file "a" is processed only once. If you need only a part of the file or of a line, assign the required value only.&lt;BR /&gt;&lt;BR /&gt;found_in_a&lt;BR /&gt;is your condition for matching lines of "a" you want to lookup in "b"; it could be something like&lt;BR /&gt;/mypattern/&lt;BR /&gt;$3 == "wow"&lt;BR /&gt;NF == 42&lt;BR /&gt;or you just leave it to get every line.&lt;BR /&gt;&lt;BR /&gt;mypatt=&lt;BR /&gt;this selects the string you want to 'grep' for in "b";&lt;BR /&gt;mypatt=$0 searches the whole line&lt;BR /&gt;mypatt=$3"-"$4"-"$5" searches for '-'seperated values of field 3 to 5.&lt;BR /&gt;&lt;BR /&gt;index function&lt;BR /&gt;if you do not need pattern for matching but a simple string, index() is your friend. If you need a regexp, use the match operator "~" or the match() function.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;mfG Peter</description>
      <pubDate>Fri, 11 Aug 2006 07:28:25 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/grep-in-awk/m-p/2491744#M98220</guid>
      <dc:creator>Peter Nikitka</dc:creator>
      <dc:date>2006-08-11T07:28:25Z</dc:date>
    </item>
    <item>
      <title>Re: Grep in AWK</title>
      <link>https://community.hpe.com/t5/operating-system-linux/grep-in-awk/m-p/2491745#M98221</link>
      <description>&lt;!--!*#--&gt;I do something pretty simple. &lt;BR /&gt;&lt;BR /&gt;if I am looking for a particular string in a field, I do the following. &lt;BR /&gt;&lt;BR /&gt;This example looks at output from ONSTAT and prints output. In this example I filter out data prior to running it against AWK as it reduces processing time by doing so. &lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;onstat -u |grep -v informix|grep -v total |awk '{print $9, $4, $5, $10, $11}' |sort -n |tail -10&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 05 Sep 2006 14:27:41 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/grep-in-awk/m-p/2491745#M98221</guid>
      <dc:creator>rmueller58</dc:creator>
      <dc:date>2006-09-05T14:27:41Z</dc:date>
    </item>
  </channel>
</rss>

