<?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: To get script  to Grep particular Pattern in Operating System - Linux</title>
    <link>https://community.hpe.com/t5/operating-system-linux/to-get-script-to-grep-particular-pattern/m-p/4099714#M92622</link>
    <description>That's rather lousy sample data!&lt;BR /&gt;No good nor bad sample match present.&lt;BR /&gt;&lt;BR /&gt;Is the list always as nice as the example?&lt;BR /&gt;If so, you could capture it in a regexpr.&lt;BR /&gt;&lt;BR /&gt;awk 'match(substr($0,3,4),/528[HJLM]/)' data&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;prior solution as 1 liner and a little shorter:&lt;BR /&gt;&lt;BR /&gt;$ awk 'BEGIN{while ((getline &amp;lt; "list") &amp;gt; 0){a[$0]=1;} } a[substr($0,3,4)]' data&lt;BR /&gt;&lt;BR /&gt;fwiw,&lt;BR /&gt;Hein.</description>
    <pubDate>Thu, 08 Nov 2007 23:59:36 GMT</pubDate>
    <dc:creator>Hein van den Heuvel</dc:creator>
    <dc:date>2007-11-08T23:59:36Z</dc:date>
    <item>
      <title>To get script  to Grep particular Pattern</title>
      <link>https://community.hpe.com/t5/operating-system-linux/to-get-script-to-grep-particular-pattern/m-p/4099712#M92620</link>
      <description>Hi Experts,&lt;BR /&gt;&lt;BR /&gt;   I am trying to select records from file (inputfile) based on a file that contains string patterns. The UNIX script must look for these all the patterns in the file in a particular location.&lt;BR /&gt; &lt;BR /&gt;e.g.&lt;BR /&gt; &lt;BR /&gt;Sample Input File&lt;BR /&gt; &lt;BR /&gt;AAAAAA8301010707010703015&lt;BR /&gt;C1$$$1107019999990403266F706F70C 4398  C 5220  C 5227  C 5401  C 5423  C 5515  C 5771  C 578402C 5789  C 5796  C 5807  C 5821  C 582501C 5859  C 6003  C 6225  C 7292  C 9770  C 990903C 993009&lt;BR /&gt;C1$$$2107019999990403266E476E47C 408703C 4398  C 5220  C 5227  C 5401  C 5423  C 5515  C 5771  C 578402C 5789  C 5796  C 5807  C 5821  C 582501C 5859  C 6003  C 6225  C 6502  C 7292  C 9770  C 990903C 993009&lt;BR /&gt;C1$$$3107019999990403266E486E48C 408703C 6502&lt;BR /&gt;C1$$$7107019999990403266F706F70C 4398  C 5220  C 5227  C 5401  C 5423  C 5515  C 5769  C 577501C 5815  C 5821  C 5857  C 6003  C 6225  C 7292  C 9770  C 990903C 993009&lt;BR /&gt;C1$$$8107019999990403266E476E47C 408703C 4398  C 5220  C 5227  C 5401  C 5423  C 5515  C 5769  C 577501C 5815  C 5821  C 5857  C 6003  C 6225  C 6502  C 7292  C 9770  C 990903C 993009&lt;BR /&gt;C1$$$9107019999990403266E486E48C 408703C 6502&lt;BR /&gt;C1***49707019999999809156F706F70C 3315  C 4084  C 4398  C 496109C 511303C 5220  C 5227  C 5423  C 5821  C 6003  C 7021  C 729201C 9770  C 990903C 993009&lt;BR /&gt;C1***59707019999999809156E476E47C 3315  C 4084  C 408703C 4398  C 496109C 511303C 5220  C 5227  C 5423  C 5821  C 6003  C 6502  C 7021  C 729201C 9770  C 990903C 993009&lt;BR /&gt;C1***69707019999999809156F706F70C 3315  C 4084  C 4398  C 496207C 511304C 5220  C 5227  C 5423  C 5821  C 6003  C 7021  C 729201C 9770  C 990903C 993009&lt;BR /&gt;C1***79707019999999809156E476E47C 3315  C 4084  C 408703C 4398  C 496207C 511304C 5220  C 5227  C 5423  C 5821  C 6003  C 6502  C 7021  C 729201C 9770  C 990903C 993009&lt;BR /&gt;C1*TT19907019999990206036F706F70C 3315  C 4084  C 4397  C 4398  C 496001C 515106C 5220  C 5227  C 5401  C 5423  C 5821  C 6003  C 7021  C 729201C 9770  C 990903C 993009&lt;BR /&gt;C1*TT29907019999990206036E476E47C 3315  C 4084  C 408703C 4397  C 4398  C 496001C 515106C 5220  C 5227  C 5401  C 5423  C 5821  C 6003  C 6502  C 7021  C 729201C 9770  C 990903C 993009&lt;BR /&gt;C1*TT39907019999990206036E486E48C 408703C 6502&lt;BR /&gt;C1*1AL9807019999990608176F706F70C 1220  C 2503  C 2851  C 3920  C 4398  C 5401  C 5537  C 993009&lt;BR /&gt;C1*1CS9707019999990608156E476E47C 408703C 4398  C 5401  C 5515  C 5769  C 5859  C 6225  C 6502  C 993009&lt;BR /&gt;C1*1DS9807019999990608216E476E47C 1700  C 3315  C 4084  C 408703C 4398  C 496109C 5401  C 551808C 6502  C 993009&lt;BR /&gt;C1*1JG9507019999990608156E476E47C 408703C 4398  C 5401  C 5515  C 6225  C 6502  C 993009&lt;BR /&gt; &lt;BR /&gt; &lt;BR /&gt;Sample Pattern File:&lt;BR /&gt; &lt;BR /&gt;528H&lt;BR /&gt;528J&lt;BR /&gt;528K&lt;BR /&gt;528L&lt;BR /&gt;528M&lt;BR /&gt; &lt;BR /&gt;I need to search for 528H in location 3 through 7 only and write the whole record to another file if there is a match.&lt;BR /&gt; &lt;BR /&gt;What I have so far:&lt;BR /&gt; &lt;BR /&gt;egrep -f pattern bi3_forms.txt &amp;gt; inbi3_forms.txt&lt;BR /&gt; &lt;BR /&gt;Problem: This command finds patterns all over the record not just from location 3 through 7.&lt;BR /&gt; &lt;BR /&gt;awk 'substr($0,3,4) == "528H"' bi3_forms.txt &amp;gt; inbi3_forms.txt&lt;BR /&gt; &lt;BR /&gt;Problem: This command finds the pattern location 3 through 7 but does not take a pattern file as input.&lt;BR /&gt; &lt;BR /&gt;Any help is greatly appreciated.&lt;BR /&gt;</description>
      <pubDate>Thu, 08 Nov 2007 22:53:13 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/to-get-script-to-grep-particular-pattern/m-p/4099712#M92620</guid>
      <dc:creator>Aakaash</dc:creator>
      <dc:date>2007-11-08T22:53:13Z</dc:date>
    </item>
    <item>
      <title>Re: To get script  to Grep particular Pattern</title>
      <link>https://community.hpe.com/t5/operating-system-linux/to-get-script-to-grep-particular-pattern/m-p/4099713#M92621</link>
      <description>awk 'BEGIN{&lt;BR /&gt;while ((getline &amp;lt; "pattFile") &amp;gt; 0) &lt;BR /&gt;{a[$0]=1;}&lt;BR /&gt;}&lt;BR /&gt;{&lt;BR /&gt;if ( a[substr($0,3,4)]) print;&lt;BR /&gt;}' inputFile &amp;gt; outFile</description>
      <pubDate>Thu, 08 Nov 2007 23:22:13 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/to-get-script-to-grep-particular-pattern/m-p/4099713#M92621</guid>
      <dc:creator>blah2blah</dc:creator>
      <dc:date>2007-11-08T23:22:13Z</dc:date>
    </item>
    <item>
      <title>Re: To get script  to Grep particular Pattern</title>
      <link>https://community.hpe.com/t5/operating-system-linux/to-get-script-to-grep-particular-pattern/m-p/4099714#M92622</link>
      <description>That's rather lousy sample data!&lt;BR /&gt;No good nor bad sample match present.&lt;BR /&gt;&lt;BR /&gt;Is the list always as nice as the example?&lt;BR /&gt;If so, you could capture it in a regexpr.&lt;BR /&gt;&lt;BR /&gt;awk 'match(substr($0,3,4),/528[HJLM]/)' data&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;prior solution as 1 liner and a little shorter:&lt;BR /&gt;&lt;BR /&gt;$ awk 'BEGIN{while ((getline &amp;lt; "list") &amp;gt; 0){a[$0]=1;} } a[substr($0,3,4)]' data&lt;BR /&gt;&lt;BR /&gt;fwiw,&lt;BR /&gt;Hein.</description>
      <pubDate>Thu, 08 Nov 2007 23:59:36 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/to-get-script-to-grep-particular-pattern/m-p/4099714#M92622</guid>
      <dc:creator>Hein van den Heuvel</dc:creator>
      <dc:date>2007-11-08T23:59:36Z</dc:date>
    </item>
    <item>
      <title>Re: To get script  to Grep particular Pattern</title>
      <link>https://community.hpe.com/t5/operating-system-linux/to-get-script-to-grep-particular-pattern/m-p/4099715#M92623</link>
      <description>You might be able to simply your request by first grepping the whole record for your keys then use awk to make sure.  That's assuming you want 528 as a prefix:&lt;BR /&gt;grep -f pattern bi3_forms.txt | awk 'substr($0,3,3) == "528"'</description>
      <pubDate>Fri, 09 Nov 2007 02:40:05 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/to-get-script-to-grep-particular-pattern/m-p/4099715#M92623</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2007-11-09T02:40:05Z</dc:date>
    </item>
    <item>
      <title>Re: To get script  to Grep particular Pattern</title>
      <link>https://community.hpe.com/t5/operating-system-linux/to-get-script-to-grep-particular-pattern/m-p/4099716#M92624</link>
      <description>If the pattern consists of only the data provided then use:&lt;BR /&gt;&lt;BR /&gt;# grep '^..528[HJKLM].*$' infile &amp;gt; outfile&lt;BR /&gt;&lt;BR /&gt;...above will locate the pattern at cols 3-7 only OR to be somewhat generic use:&lt;BR /&gt;&lt;BR /&gt;# grep '^..[0-9]\{3\}[HJKLM].*$' infile &amp;gt; outfile&lt;BR /&gt;&lt;BR /&gt;...above will locate the pattern that has 3 digits followed by either H/J/K/L/M in cols 3-7. Or you could use the one below to locate the pattern that has 3 digits followed by an uppercase alphabet:&lt;BR /&gt;&lt;BR /&gt;# grep '^..[0-9]\{3\}[A-Z].*$' infile &amp;gt; outfile&lt;BR /&gt;&lt;BR /&gt;Or to locate the pattern that has 3 digits followed by an upper/lower case alphabet use:&lt;BR /&gt;&lt;BR /&gt;# grep '^..[0-9]\{3\}[A-Za-z].*$' infile &amp;gt; outfile&lt;BR /&gt;&lt;BR /&gt;~hope it helps</description>
      <pubDate>Fri, 09 Nov 2007 12:28:00 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/to-get-script-to-grep-particular-pattern/m-p/4099716#M92624</guid>
      <dc:creator>Sandman!</dc:creator>
      <dc:date>2007-11-09T12:28:00Z</dc:date>
    </item>
    <item>
      <title>Re: To get script  to Grep particular Pattern</title>
      <link>https://community.hpe.com/t5/operating-system-linux/to-get-script-to-grep-particular-pattern/m-p/4099717#M92625</link>
      <description>Hi,&lt;BR /&gt;use this sample pattern file:&lt;BR /&gt;..528H&lt;BR /&gt;..528J&lt;BR /&gt;..528K&lt;BR /&gt;..528L&lt;BR /&gt;..528M&lt;BR /&gt;&lt;BR /&gt;grep -f pattern b13_forms.txt&lt;BR /&gt;&lt;BR /&gt;and teh grep will look for the pattern starting in position 3.&lt;BR /&gt;&lt;BR /&gt;HTH,&lt;BR /&gt;Art</description>
      <pubDate>Mon, 12 Nov 2007 03:20:34 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/to-get-script-to-grep-particular-pattern/m-p/4099717#M92625</guid>
      <dc:creator>Arturo Galbiati</dc:creator>
      <dc:date>2007-11-12T03:20:34Z</dc:date>
    </item>
    <item>
      <title>Re: To get script  to Grep particular Pattern</title>
      <link>https://community.hpe.com/t5/operating-system-linux/to-get-script-to-grep-particular-pattern/m-p/4099718#M92626</link>
      <description>&amp;gt;Art: use this sample pattern file: ..528H&lt;BR /&gt;&amp;gt;grep will look for the pattern starting in position 3.&lt;BR /&gt;&lt;BR /&gt;You need to anchor each pattern otherwise it will find it in other columns:&lt;BR /&gt;^..528H</description>
      <pubDate>Mon, 12 Nov 2007 06:13:54 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/to-get-script-to-grep-particular-pattern/m-p/4099718#M92626</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2007-11-12T06:13:54Z</dc:date>
    </item>
    <item>
      <title>Re: To get script  to Grep particular Pattern</title>
      <link>https://community.hpe.com/t5/operating-system-linux/to-get-script-to-grep-particular-pattern/m-p/4099719#M92627</link>
      <description>Use&lt;BR /&gt;&lt;BR /&gt;If you want to collect 528[HJKLM] from 3rd char or from 4th char or 7th char etc, you can use&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;grep -e '^..528[HJKLM]' -e '^...528[HJKLM]' -e '^....528[HJKLM]' -e '^.....528[HJKLM]' -e '^......528[HJKLM]' &lt;YOUR log="" file="" name=""&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Rgds &lt;BR /&gt;-NKG-&lt;/YOUR&gt;</description>
      <pubDate>Thu, 29 Nov 2007 05:55:29 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/to-get-script-to-grep-particular-pattern/m-p/4099719#M92627</guid>
      <dc:creator>Nitin Kumar Gupta</dc:creator>
      <dc:date>2007-11-29T05:55:29Z</dc:date>
    </item>
  </channel>
</rss>

