<?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: awk and pattern matching in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-and-pattern-matching/m-p/2889416#M102575</link>
    <description>Hi,&lt;BR /&gt;&lt;BR /&gt;Have you tried just to match the two variables, it should be possible (if you dont have a very old version of awk).&lt;BR /&gt;&lt;BR /&gt;$4 == &lt;VARIABLE&gt; { do something }&lt;/VARIABLE&gt;</description>
    <pubDate>Thu, 23 Jan 2003 15:24:45 GMT</pubDate>
    <dc:creator>Leif Halvarsson_2</dc:creator>
    <dc:date>2003-01-23T15:24:45Z</dc:date>
    <item>
      <title>awk and pattern matching</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-and-pattern-matching/m-p/2889413#M102572</link>
      <description>&lt;BR /&gt;How do you perform pattern matching with awk using a variable instead of plain text?&lt;BR /&gt;&lt;BR /&gt;example:&lt;BR /&gt;&lt;BR /&gt;awk '{$4="match_this_text" print .....}'&lt;BR /&gt;&lt;BR /&gt;In the example above I want to use a variable name for the string "match_this_text".&lt;BR /&gt;&lt;BR /&gt;Tony&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 23 Jan 2003 15:02:04 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-and-pattern-matching/m-p/2889413#M102572</guid>
      <dc:creator>Anthony deRito</dc:creator>
      <dc:date>2003-01-23T15:02:04Z</dc:date>
    </item>
    <item>
      <title>Re: awk and pattern matching</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-and-pattern-matching/m-p/2889414#M102573</link>
      <description>use the match() function:&lt;BR /&gt;&lt;BR /&gt;awk '{ if (match($4,"match_this_text") ... }'</description>
      <pubDate>Thu, 23 Jan 2003 15:10:24 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-and-pattern-matching/m-p/2889414#M102573</guid>
      <dc:creator>Jdamian</dc:creator>
      <dc:date>2003-01-23T15:10:24Z</dc:date>
    </item>
    <item>
      <title>Re: awk and pattern matching</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-and-pattern-matching/m-p/2889415#M102574</link>
      <description>export MATCHTXT="match_this_text"&lt;BR /&gt;&lt;BR /&gt;awk -v matchvar=$MATCHTXT '$4 == matchvar { print "found it!"}&lt;BR /&gt;&lt;BR /&gt;Alternatively, put literal text in -v portion of awk line.&lt;BR /&gt;&lt;BR /&gt;Share and Enjoy! Ian</description>
      <pubDate>Thu, 23 Jan 2003 15:18:43 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-and-pattern-matching/m-p/2889415#M102574</guid>
      <dc:creator>Ian Dennison_1</dc:creator>
      <dc:date>2003-01-23T15:18:43Z</dc:date>
    </item>
    <item>
      <title>Re: awk and pattern matching</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-and-pattern-matching/m-p/2889416#M102575</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;Have you tried just to match the two variables, it should be possible (if you dont have a very old version of awk).&lt;BR /&gt;&lt;BR /&gt;$4 == &lt;VARIABLE&gt; { do something }&lt;/VARIABLE&gt;</description>
      <pubDate>Thu, 23 Jan 2003 15:24:45 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-and-pattern-matching/m-p/2889416#M102575</guid>
      <dc:creator>Leif Halvarsson_2</dc:creator>
      <dc:date>2003-01-23T15:24:45Z</dc:date>
    </item>
    <item>
      <title>Re: awk and pattern matching</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-and-pattern-matching/m-p/2889417#M102576</link>
      <description>ls -l | awk '{if($5=="May" &amp;amp;&amp;amp; $6=="7") print $NF }'&lt;BR /&gt;&lt;BR /&gt;will print all files created witht the date May 7th &lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;I hope this clears the syntax.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Manoj Srivastava</description>
      <pubDate>Thu, 23 Jan 2003 15:28:31 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-and-pattern-matching/m-p/2889417#M102576</guid>
      <dc:creator>MANOJ SRIVASTAVA</dc:creator>
      <dc:date>2003-01-23T15:28:31Z</dc:date>
    </item>
    <item>
      <title>Re: awk and pattern matching</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-and-pattern-matching/m-p/2889418#M102577</link>
      <description>The pattern match operator is "~" when put in the pattern field-&lt;BR /&gt;&lt;BR /&gt;Here is an example-&lt;BR /&gt;&lt;BR /&gt;awk '$4~/ab.*yz/{print ...}'&lt;BR /&gt;&lt;BR /&gt;HTH&lt;BR /&gt;&lt;BR /&gt;-- Rod Hills</description>
      <pubDate>Thu, 23 Jan 2003 15:33:08 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-and-pattern-matching/m-p/2889418#M102577</guid>
      <dc:creator>Rodney Hills</dc:creator>
      <dc:date>2003-01-23T15:33:08Z</dc:date>
    </item>
    <item>
      <title>Re: awk and pattern matching</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-and-pattern-matching/m-p/2889419#M102578</link>
      <description>export TEXT_STR=your_string&lt;BR /&gt;awk -v match_this_text=${TEXT_STR} '{if($4 == match_this_string) print .... }' file_name</description>
      <pubDate>Thu, 23 Jan 2003 15:48:11 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-and-pattern-matching/m-p/2889419#M102578</guid>
      <dc:creator>Ian Lochray</dc:creator>
      <dc:date>2003-01-23T15:48:11Z</dc:date>
    </item>
    <item>
      <title>Re: awk and pattern matching</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-and-pattern-matching/m-p/2889420#M102579</link>
      <description>I solved a problem where I wanted to find all lines in the /var/adm/syslog/mail.log file, belonging to mail to or from a specific e-mail address. There are two different lines for every message. The common information is a message ID in one field.&lt;BR /&gt;&lt;BR /&gt;I made an awk script that generated a new awk script that had all the pattern matches as strings generated from variables in the first script.&lt;BR /&gt;&lt;BR /&gt;Something like:&lt;BR /&gt;&lt;BR /&gt;awk '/to:e-mail addres/ {print "/"$3"/ {what should be done }' &amp;gt; scriptfilename.awk&lt;BR /&gt;&lt;BR /&gt;The final script was made to look someting like:&lt;BR /&gt;/first found message ID/ {what should be done}&lt;BR /&gt;/other found message ID/ {what should be done}&lt;BR /&gt;...&lt;BR /&gt;&lt;BR /&gt;The generated script was run with&lt;BR /&gt;awk -f scriptfilename.awk inputfile&lt;BR /&gt;&lt;BR /&gt;With BEGIN and END filters You could also generate BEGIN and END in the second awk script.&lt;BR /&gt;&lt;BR /&gt;Good luck!&lt;BR /&gt;Rolf&lt;BR /&gt;</description>
      <pubDate>Fri, 01 Aug 2003 13:56:19 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-and-pattern-matching/m-p/2889420#M102579</guid>
      <dc:creator>Rolf Modin</dc:creator>
      <dc:date>2003-08-01T13:56:19Z</dc:date>
    </item>
  </channel>
</rss>

