<?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: need to pass in variable as regular expression in awk in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/need-to-pass-in-variable-as-regular-expression-in-awk/m-p/3406425#M706459</link>
    <description>okay, would this work?&lt;BR /&gt;&lt;BR /&gt;/\\/'$LINE$'\\//&lt;BR /&gt;&lt;BR /&gt;I think it's just a matter of finding the right number of escapes...&lt;BR /&gt;&lt;BR /&gt;Rgds...Geoff</description>
    <pubDate>Sat, 23 Oct 2004 10:29:01 GMT</pubDate>
    <dc:creator>Geoff Wild</dc:creator>
    <dc:date>2004-10-23T10:29:01Z</dc:date>
    <item>
      <title>need to pass in variable as regular expression in awk</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/need-to-pass-in-variable-as-regular-expression-in-awk/m-p/3406422#M706456</link>
      <description>How do I pass in a variable as a search pattern in my awk statement?&lt;BR /&gt;&lt;BR /&gt;I have a line read from a file and I am trying to use that line as an expression in awk. It breaks down like this:&lt;BR /&gt;&lt;BR /&gt;cat locks.tmp | while read LINE&lt;BR /&gt;do&lt;BR /&gt;&lt;BR /&gt;awk  '/spid/{x=1;y=0}/$LINE/ {if (y&amp;gt;3){l[y]="\n"; while(i++&lt;Y&gt;&lt;/Y&gt;&lt;BR /&gt;I have tried using -v line=$LINE and then /.../.../line/ but it's not working...&lt;BR /&gt;&lt;BR /&gt;The line looks like :&lt;BR /&gt;TYES Lock =&amp;gt; Oct 23, 2004 00:14:45     - te_tyesp04_20 - 64&lt;BR /&gt;&lt;BR /&gt;Anyone have any ideas???</description>
      <pubDate>Sat, 23 Oct 2004 09:48:24 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/need-to-pass-in-variable-as-regular-expression-in-awk/m-p/3406422#M706456</guid>
      <dc:creator>Jamie Collins</dc:creator>
      <dc:date>2004-10-23T09:48:24Z</dc:date>
    </item>
    <item>
      <title>Re: need to pass in variable as regular expression in awk</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/need-to-pass-in-variable-as-regular-expression-in-awk/m-p/3406423#M706457</link>
      <description>What if you put the $LINE in single quotes?&lt;BR /&gt;&lt;BR /&gt;/'$LINE'&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;IMHO - this would be better in perl - but I'm far from a perl guru - maybe Merijn can help you out  :)&lt;BR /&gt;&lt;BR /&gt;Rgds...Geoff</description>
      <pubDate>Sat, 23 Oct 2004 10:22:11 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/need-to-pass-in-variable-as-regular-expression-in-awk/m-p/3406423#M706457</guid>
      <dc:creator>Geoff Wild</dc:creator>
      <dc:date>2004-10-23T10:22:11Z</dc:date>
    </item>
    <item>
      <title>Re: need to pass in variable as regular expression in awk</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/need-to-pass-in-variable-as-regular-expression-in-awk/m-p/3406424#M706458</link>
      <description>I think if I put it in single quotes the first one would end the one outside my awk...&lt;BR /&gt;&lt;BR /&gt;awk '/......   /  '$LINE.....</description>
      <pubDate>Sat, 23 Oct 2004 10:23:41 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/need-to-pass-in-variable-as-regular-expression-in-awk/m-p/3406424#M706458</guid>
      <dc:creator>Jamie Collins</dc:creator>
      <dc:date>2004-10-23T10:23:41Z</dc:date>
    </item>
    <item>
      <title>Re: need to pass in variable as regular expression in awk</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/need-to-pass-in-variable-as-regular-expression-in-awk/m-p/3406425#M706459</link>
      <description>okay, would this work?&lt;BR /&gt;&lt;BR /&gt;/\\/'$LINE$'\\//&lt;BR /&gt;&lt;BR /&gt;I think it's just a matter of finding the right number of escapes...&lt;BR /&gt;&lt;BR /&gt;Rgds...Geoff</description>
      <pubDate>Sat, 23 Oct 2004 10:29:01 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/need-to-pass-in-variable-as-regular-expression-in-awk/m-p/3406425#M706459</guid>
      <dc:creator>Geoff Wild</dc:creator>
      <dc:date>2004-10-23T10:29:01Z</dc:date>
    </item>
    <item>
      <title>Re: need to pass in variable as regular expression in awk</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/need-to-pass-in-variable-as-regular-expression-in-awk/m-p/3406426#M706460</link>
      <description>I think you're right...  but interestingly if I hardcode the LINE value...&lt;BR /&gt;&lt;BR /&gt;awk -v line="TYES Lock =&amp;gt; Oct 23, 2004 10:12:57     - te_tyesp05_25 - 146" '/spid/{x=1;y=0}/line/ {if (y&amp;gt;3){l[y]="\n"; while(i++&lt;Y&gt;&lt;/Y&gt;&lt;BR /&gt;using it with -v doesn't work but if I don't use the -v...&lt;BR /&gt;&lt;BR /&gt;awk '/spid/{x=1;y=0}/TYES Lock =&amp;gt; Oct 23, 2004 10:12:57     - te_tyesp05_25 - 146" '/spid/{x=1;y=0}/line/ {if (y&amp;gt;3){l[y]="\n"; while(i++&lt;Y&gt;&lt;/Y&gt;&lt;BR /&gt;I get what I'm looking for...&lt;BR /&gt;I just need a way to use the $LINE variable in my regular expression....</description>
      <pubDate>Sat, 23 Oct 2004 10:35:37 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/need-to-pass-in-variable-as-regular-expression-in-awk/m-p/3406426#M706460</guid>
      <dc:creator>Jamie Collins</dc:creator>
      <dc:date>2004-10-23T10:35:37Z</dc:date>
    </item>
    <item>
      <title>Re: need to pass in variable as regular expression in awk</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/need-to-pass-in-variable-as-regular-expression-in-awk/m-p/3406427#M706461</link>
      <description>Correction.. the last part should look like this:&lt;BR /&gt;&lt;BR /&gt;awk '/spid/{x=1;y=0}/TYES Lock =&amp;gt; Oct 23, 2004 10:12:57 - te_tyesp05_25 - 146/ {if (y&amp;gt;3){l[y]="\n"; while(i++&lt;Y&gt;&lt;/Y&gt;&lt;BR /&gt;It also doesn't like it if I put the actual LINE in quotes...&lt;BR /&gt;&lt;BR /&gt;awk '/spid/{x=1;y=0}/"TYES Lock =&amp;gt; Oct 23, 2004 10:12:57 - te_tyesp05_25 - 146"/ {if (y&amp;gt;3){l[y]="\n"; while(i++&lt;Y&gt;&lt;/Y&gt;&lt;BR /&gt;Wonder why the line variable doesn't work??</description>
      <pubDate>Sat, 23 Oct 2004 11:02:20 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/need-to-pass-in-variable-as-regular-expression-in-awk/m-p/3406427#M706461</guid>
      <dc:creator>Jamie Collins</dc:creator>
      <dc:date>2004-10-23T11:02:20Z</dc:date>
    </item>
  </channel>
</rss>

