<?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 problem in Operating System - Linux</title>
    <link>https://community.hpe.com/t5/operating-system-linux/awk-problem/m-p/3676881#M53400</link>
    <description>I did try to use ";" but if I do that, I got a different result.&lt;BR /&gt;&lt;BR /&gt;see below&lt;BR /&gt;&lt;BR /&gt;awk '/abc|cde/; END{ print "---&amp;gt;" $1}' file&lt;BR /&gt;abc test&lt;BR /&gt;cde test&lt;BR /&gt;---&amp;gt;test&lt;BR /&gt;&lt;BR /&gt;awk '/abc|cde/ END{ print "---&amp;gt;" $1}' file&lt;BR /&gt;awk: cmd. line:1: /abc|cde/ END{ print "---&amp;gt;" $1}&lt;BR /&gt;awk: cmd. line:1:           ^ parse error&lt;BR /&gt;&lt;BR /&gt;awk '/abc|cde/ { print "---&amp;gt;" $1}' file&lt;BR /&gt;---&amp;gt;abc&lt;BR /&gt;---&amp;gt;cde&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;the last one is the right answer.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
    <pubDate>Tue, 22 Nov 2005 16:14:49 GMT</pubDate>
    <dc:creator>Gemini_2</dc:creator>
    <dc:date>2005-11-22T16:14:49Z</dc:date>
    <item>
      <title>awk problem</title>
      <link>https://community.hpe.com/t5/operating-system-linux/awk-problem/m-p/3676869#M53388</link>
      <description>when I run&lt;BR /&gt;&lt;BR /&gt;awk '/abc|cde/ END{ print "---&amp;gt;" $1}'  file&lt;BR /&gt;awk: cmd. line:1: /abc|cde/ END{ print "---&amp;gt;" $1}&lt;BR /&gt;awk: cmd. line:1:           ^ parse error&lt;BR /&gt;&lt;BR /&gt;I got parse error...why?&lt;BR /&gt;&lt;BR /&gt;hmmm..&lt;BR /&gt;&lt;BR /&gt;thank u</description>
      <pubDate>Tue, 22 Nov 2005 15:21:52 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/awk-problem/m-p/3676869#M53388</guid>
      <dc:creator>Gemini_2</dc:creator>
      <dc:date>2005-11-22T15:21:52Z</dc:date>
    </item>
    <item>
      <title>Re: awk problem</title>
      <link>https://community.hpe.com/t5/operating-system-linux/awk-problem/m-p/3676870#M53389</link>
      <description>Hi:&lt;BR /&gt;&lt;BR /&gt;This works for me as written (and I cut-and-pasted from this post).&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Tue, 22 Nov 2005 15:34:20 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/awk-problem/m-p/3676870#M53389</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2005-11-22T15:34:20Z</dc:date>
    </item>
    <item>
      <title>Re: awk problem</title>
      <link>https://community.hpe.com/t5/operating-system-linux/awk-problem/m-p/3676871#M53390</link>
      <description>I don't see anything wrong at all. Is this HP-UX?</description>
      <pubDate>Tue, 22 Nov 2005 15:38:39 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/awk-problem/m-p/3676871#M53390</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2005-11-22T15:38:39Z</dc:date>
    </item>
    <item>
      <title>Re: awk problem</title>
      <link>https://community.hpe.com/t5/operating-system-linux/awk-problem/m-p/3676872#M53391</link>
      <description>It ran ok on my system. &lt;BR /&gt; &lt;BR /&gt;Could you have an unprintable character in the command?&lt;BR /&gt; &lt;BR /&gt;Rod Hills</description>
      <pubDate>Tue, 22 Nov 2005 15:39:04 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/awk-problem/m-p/3676872#M53391</guid>
      <dc:creator>Rodney Hills</dc:creator>
      <dc:date>2005-11-22T15:39:04Z</dc:date>
    </item>
    <item>
      <title>Re: awk problem</title>
      <link>https://community.hpe.com/t5/operating-system-linux/awk-problem/m-p/3676873#M53392</link>
      <description>Is it possible you have "awk" aliased to something else?&lt;BR /&gt; &lt;BR /&gt;Enter "alias" and look to see if awk is defined.&lt;BR /&gt; &lt;BR /&gt;Rod Hills</description>
      <pubDate>Tue, 22 Nov 2005 15:40:18 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/awk-problem/m-p/3676873#M53392</guid>
      <dc:creator>Rodney Hills</dc:creator>
      <dc:date>2005-11-22T15:40:18Z</dc:date>
    </item>
    <item>
      <title>Re: awk problem</title>
      <link>https://community.hpe.com/t5/operating-system-linux/awk-problem/m-p/3676874#M53393</link>
      <description>I dont think that I have any unprintable characters..&lt;BR /&gt;&lt;BR /&gt;very change.....&lt;BR /&gt;&lt;BR /&gt;I am using linux system, does it matter?&lt;BR /&gt;&lt;BR /&gt;awk is just awk right?</description>
      <pubDate>Tue, 22 Nov 2005 15:41:10 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/awk-problem/m-p/3676874#M53393</guid>
      <dc:creator>Gemini_2</dc:creator>
      <dc:date>2005-11-22T15:41:10Z</dc:date>
    </item>
    <item>
      <title>Re: awk problem</title>
      <link>https://community.hpe.com/t5/operating-system-linux/awk-problem/m-p/3676875#M53394</link>
      <description>For the most part. awk is awk.&lt;BR /&gt; &lt;BR /&gt;The history of awk includes a version called "new awk" or "nawk", then you have the gnu version.&lt;BR /&gt; &lt;BR /&gt;Although your line is very simple and should be runable. Try replacing the "---&amp;gt;" with just "###". In case the "&amp;gt;" is being processed by awk for file redirection.&lt;BR /&gt; &lt;BR /&gt;Rod Hills</description>
      <pubDate>Tue, 22 Nov 2005 15:44:57 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/awk-problem/m-p/3676875#M53394</guid>
      <dc:creator>Rodney Hills</dc:creator>
      <dc:date>2005-11-22T15:44:57Z</dc:date>
    </item>
    <item>
      <title>Re: awk problem</title>
      <link>https://community.hpe.com/t5/operating-system-linux/awk-problem/m-p/3676876#M53395</link>
      <description>Hi (again):&lt;BR /&gt;&lt;BR /&gt;Well, 'awk' is 'awk' just like UNIX is UNIX.  There *ARE* variations.  You might see if you have a "new" awk --- 'nawk'.&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Tue, 22 Nov 2005 15:46:21 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/awk-problem/m-p/3676876#M53395</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2005-11-22T15:46:21Z</dc:date>
    </item>
    <item>
      <title>Re: awk problem</title>
      <link>https://community.hpe.com/t5/operating-system-linux/awk-problem/m-p/3676877#M53396</link>
      <description>No awk is not just awk. The Gnu awk which is almost certainly your Linux version. The nawk (new awk - at least 20 years old which is HP-UX} and there is oawk (old awk) oawk is 'awk' on Solaris; nawk is awk on HP-UX; and gawk is awk on Linux.&lt;BR /&gt;&lt;BR /&gt;I suspect that if you remove the 'END' your script will run.</description>
      <pubDate>Tue, 22 Nov 2005 15:47:12 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/awk-problem/m-p/3676877#M53396</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2005-11-22T15:47:12Z</dc:date>
    </item>
    <item>
      <title>Re: awk problem</title>
      <link>https://community.hpe.com/t5/operating-system-linux/awk-problem/m-p/3676878#M53397</link>
      <description>Yes, if I took out "END", it will run, but I need END to do OFS=":"&lt;BR /&gt;&lt;BR /&gt;gawk '/abc|cde/ END { OFS=":", print "**" $1}' file&lt;BR /&gt;&lt;BR /&gt;thank you for trying...&lt;BR /&gt;maybe gnu awk works funny..</description>
      <pubDate>Tue, 22 Nov 2005 15:54:52 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/awk-problem/m-p/3676878#M53397</guid>
      <dc:creator>Gemini_2</dc:creator>
      <dc:date>2005-11-22T15:54:52Z</dc:date>
    </item>
    <item>
      <title>Re: awk problem</title>
      <link>https://community.hpe.com/t5/operating-system-linux/awk-problem/m-p/3676879#M53398</link>
      <description>Hi (again):&lt;BR /&gt;&lt;BR /&gt;Try adding a semicolon after the regular expression and before the END block.&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Tue, 22 Nov 2005 15:59:02 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/awk-problem/m-p/3676879#M53398</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2005-11-22T15:59:02Z</dc:date>
    </item>
    <item>
      <title>Re: awk problem</title>
      <link>https://community.hpe.com/t5/operating-system-linux/awk-problem/m-p/3676880#M53399</link>
      <description>Okay. In that case you need a null statement. Insert a ';' (without the quotes) before the END. That should work on all awk flavors. I suspect a newline would work as well but you have quoted this one-liner so a ; as a null statement is probably the better choice.</description>
      <pubDate>Tue, 22 Nov 2005 16:02:52 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/awk-problem/m-p/3676880#M53399</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2005-11-22T16:02:52Z</dc:date>
    </item>
    <item>
      <title>Re: awk problem</title>
      <link>https://community.hpe.com/t5/operating-system-linux/awk-problem/m-p/3676881#M53400</link>
      <description>I did try to use ";" but if I do that, I got a different result.&lt;BR /&gt;&lt;BR /&gt;see below&lt;BR /&gt;&lt;BR /&gt;awk '/abc|cde/; END{ print "---&amp;gt;" $1}' file&lt;BR /&gt;abc test&lt;BR /&gt;cde test&lt;BR /&gt;---&amp;gt;test&lt;BR /&gt;&lt;BR /&gt;awk '/abc|cde/ END{ print "---&amp;gt;" $1}' file&lt;BR /&gt;awk: cmd. line:1: /abc|cde/ END{ print "---&amp;gt;" $1}&lt;BR /&gt;awk: cmd. line:1:           ^ parse error&lt;BR /&gt;&lt;BR /&gt;awk '/abc|cde/ { print "---&amp;gt;" $1}' file&lt;BR /&gt;---&amp;gt;abc&lt;BR /&gt;---&amp;gt;cde&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;the last one is the right answer.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 22 Nov 2005 16:14:49 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/awk-problem/m-p/3676881#M53400</guid>
      <dc:creator>Gemini_2</dc:creator>
      <dc:date>2005-11-22T16:14:49Z</dc:date>
    </item>
    <item>
      <title>Re: awk problem</title>
      <link>https://community.hpe.com/t5/operating-system-linux/awk-problem/m-p/3676882#M53401</link>
      <description>Hi (again):&lt;BR /&gt;&lt;BR /&gt;The last one is the CORRECT result based on what you wrote.  The inference is to print lines that match the regular expresssion.  Then, the END block is executed to print the "---&amp;gt;" and the first field of the last record processed.&lt;BR /&gt;&lt;BR /&gt;If all you want is to print "---&amp;gt;" in front of matches do:&lt;BR /&gt;&lt;BR /&gt;# awk '/abc|cde/ { print "---&amp;gt;" $1}' file&lt;BR /&gt;&lt;BR /&gt;Of course, this assumes that the first field ($1) is what you want to point at.&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 22 Nov 2005 16:24:32 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/awk-problem/m-p/3676882#M53401</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2005-11-22T16:24:32Z</dc:date>
    </item>
    <item>
      <title>Re: awk problem</title>
      <link>https://community.hpe.com/t5/operating-system-linux/awk-problem/m-p/3676883#M53402</link>
      <description>thank you all..&lt;BR /&gt;&lt;BR /&gt;I ended up using BEGIN..and rewrote my awk statement....&lt;BR /&gt;&lt;BR /&gt;I will assign everyone some points for helping out!!&lt;BR /&gt;&lt;BR /&gt;thank you very much AGAIN&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 22 Nov 2005 16:29:23 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/awk-problem/m-p/3676883#M53402</guid>
      <dc:creator>Gemini_2</dc:creator>
      <dc:date>2005-11-22T16:29:23Z</dc:date>
    </item>
    <item>
      <title>Re: awk problem</title>
      <link>https://community.hpe.com/t5/operating-system-linux/awk-problem/m-p/3676884#M53403</link>
      <description>It would probably make more sense to describe what you want done rather than telling us about parsing errors.&lt;BR /&gt;&lt;BR /&gt;Even your example is not clear because your input file is so sparse. With only the last line left as input, it's not easy to follow your expectations.&lt;BR /&gt;&lt;BR /&gt;One trick would be to use  "{exit}" as soon as a pattern match is found. The exit function imediately triggers the END block (if it exists).</description>
      <pubDate>Tue, 22 Nov 2005 16:32:23 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/awk-problem/m-p/3676884#M53403</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2005-11-22T16:32:23Z</dc:date>
    </item>
    <item>
      <title>Re: awk problem</title>
      <link>https://community.hpe.com/t5/operating-system-linux/awk-problem/m-p/3676885#M53404</link>
      <description>yes, you are right.&lt;BR /&gt;&lt;BR /&gt;I realized that I should give a sample file and a sample output, then it will much better.&lt;BR /&gt;&lt;BR /&gt;next time!!&lt;BR /&gt;&lt;BR /&gt;thanks all anyway!!&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 22 Nov 2005 19:16:00 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/awk-problem/m-p/3676885#M53404</guid>
      <dc:creator>Gemini_2</dc:creator>
      <dc:date>2005-11-22T19:16:00Z</dc:date>
    </item>
  </channel>
</rss>

