<?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 grep help in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/grep-help/m-p/4467977#M360737</link>
    <description>Hi &lt;BR /&gt;&lt;BR /&gt;i have a file with series of entries with 4 lines each in a group&lt;BR /&gt;&lt;BR /&gt;How can i search for a pattern and print all the 4 lines&lt;BR /&gt;&lt;BR /&gt;checking bbb on xny&lt;BR /&gt;The Password Aging policy is==&amp;gt;  DISABLED&lt;BR /&gt;The Account Life time  ==&amp;gt; NEVER EXPIRES&lt;BR /&gt;Number of unsuccesful logins Allowed ==&amp;gt; INFINITE&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;checking qwe  on qwqw&lt;BR /&gt;The Password Aging policy is==&amp;gt;  DISABLED&lt;BR /&gt;The Account Life time  ==&amp;gt; NEVER EXPIRES&lt;BR /&gt;Number of unsuccesful logins Allowed ==&amp;gt; INFINITE&lt;BR /&gt;&lt;BR /&gt;checking eqw on inqw&lt;BR /&gt;The Password Aging policy is==&amp;gt;  DISABLED&lt;BR /&gt;The Account Life time  ==&amp;gt; NEVER EXPIRES&lt;BR /&gt;Number of unsuccesful logins Allowed ==&amp;gt; DEFAULT&lt;BR /&gt;&lt;BR /&gt;checking eqw on inqw&lt;BR /&gt;The Password Aging policy is==&amp;gt;  DISABLED&lt;BR /&gt;The Account Life time  ==&amp;gt; NEVER EXPIRES&lt;BR /&gt;Number of unsuccesful logins Allowed ==&amp;gt; INFINITE&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;for the one that has DEFAULT i want to print out the 4 lines above that &lt;BR /&gt;&lt;BR /&gt;checking eqw on inqw&lt;BR /&gt;The Password Aging policy is==&amp;gt;  DISABLED&lt;BR /&gt;The Account Life time  ==&amp;gt; NEVER EXPIRES&lt;BR /&gt;Number of unsuccesful logins Allowed ==&amp;gt; DEFAULT&lt;BR /&gt;&lt;BR /&gt;how can i do this?&lt;BR /&gt;&lt;BR /&gt;Thanks in advance&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
    <pubDate>Tue, 28 Jul 2009 09:39:46 GMT</pubDate>
    <dc:creator>George Chechakunnil</dc:creator>
    <dc:date>2009-07-28T09:39:46Z</dc:date>
    <item>
      <title>grep help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/grep-help/m-p/4467977#M360737</link>
      <description>Hi &lt;BR /&gt;&lt;BR /&gt;i have a file with series of entries with 4 lines each in a group&lt;BR /&gt;&lt;BR /&gt;How can i search for a pattern and print all the 4 lines&lt;BR /&gt;&lt;BR /&gt;checking bbb on xny&lt;BR /&gt;The Password Aging policy is==&amp;gt;  DISABLED&lt;BR /&gt;The Account Life time  ==&amp;gt; NEVER EXPIRES&lt;BR /&gt;Number of unsuccesful logins Allowed ==&amp;gt; INFINITE&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;checking qwe  on qwqw&lt;BR /&gt;The Password Aging policy is==&amp;gt;  DISABLED&lt;BR /&gt;The Account Life time  ==&amp;gt; NEVER EXPIRES&lt;BR /&gt;Number of unsuccesful logins Allowed ==&amp;gt; INFINITE&lt;BR /&gt;&lt;BR /&gt;checking eqw on inqw&lt;BR /&gt;The Password Aging policy is==&amp;gt;  DISABLED&lt;BR /&gt;The Account Life time  ==&amp;gt; NEVER EXPIRES&lt;BR /&gt;Number of unsuccesful logins Allowed ==&amp;gt; DEFAULT&lt;BR /&gt;&lt;BR /&gt;checking eqw on inqw&lt;BR /&gt;The Password Aging policy is==&amp;gt;  DISABLED&lt;BR /&gt;The Account Life time  ==&amp;gt; NEVER EXPIRES&lt;BR /&gt;Number of unsuccesful logins Allowed ==&amp;gt; INFINITE&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;for the one that has DEFAULT i want to print out the 4 lines above that &lt;BR /&gt;&lt;BR /&gt;checking eqw on inqw&lt;BR /&gt;The Password Aging policy is==&amp;gt;  DISABLED&lt;BR /&gt;The Account Life time  ==&amp;gt; NEVER EXPIRES&lt;BR /&gt;Number of unsuccesful logins Allowed ==&amp;gt; DEFAULT&lt;BR /&gt;&lt;BR /&gt;how can i do this?&lt;BR /&gt;&lt;BR /&gt;Thanks in advance&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 28 Jul 2009 09:39:46 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/grep-help/m-p/4467977#M360737</guid>
      <dc:creator>George Chechakunnil</dc:creator>
      <dc:date>2009-07-28T09:39:46Z</dc:date>
    </item>
    <item>
      <title>Re: grep help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/grep-help/m-p/4467978#M360738</link>
      <description>&lt;!--!*#--&gt;George,&lt;BR /&gt;&lt;BR /&gt;From "Handy One-Liners for Sed" (attached):&lt;BR /&gt;&lt;BR /&gt;# print paragraph if it contains AAA (blank lines separate paragraphs)&lt;BR /&gt; # HHsed v1.5 must insert a 'G;' after 'x;' in the next 3 scripts below&lt;BR /&gt; sed -e '/./{H;$!d;}' -e 'x;/AAA/!d;'&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Pete</description>
      <pubDate>Tue, 28 Jul 2009 09:52:10 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/grep-help/m-p/4467978#M360738</guid>
      <dc:creator>Pete Randall</dc:creator>
      <dc:date>2009-07-28T09:52:10Z</dc:date>
    </item>
    <item>
      <title>Re: grep help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/grep-help/m-p/4467979#M360739</link>
      <description>Hi :&lt;BR /&gt;&lt;BR /&gt;You could do :&lt;BR /&gt;&lt;BR /&gt;# perl -e '$/="";while (&amp;lt;&amp;gt;) {print if /DEFAULT/}' file&lt;BR /&gt;&lt;BR /&gt;or:&lt;BR /&gt;&lt;BR /&gt;# awk 'BEGIN{RS=""};/DEFAULT/ {print}' file&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Tue, 28 Jul 2009 10:37:47 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/grep-help/m-p/4467979#M360739</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2009-07-28T10:37:47Z</dc:date>
    </item>
    <item>
      <title>Re: grep help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/grep-help/m-p/4467980#M360740</link>
      <description>&amp;gt;JRF: # perl -e '$/="";while (&amp;lt;&amp;gt;) {print if /DEFAULT/}' file&lt;BR /&gt;&amp;gt;# awk 'BEGIN{RS=""};/DEFAULT/ {print}' file&lt;BR /&gt;&lt;BR /&gt;I'm not sure how these print out the previous 3 lines and the line with DEFAULT?&lt;BR /&gt;I'm assuming the files have zillions of lines and possibly a few of these 4 line blocks.&lt;BR /&gt;&lt;BR /&gt;Of course here GNU grep would work with -B3.</description>
      <pubDate>Tue, 28 Jul 2009 16:03:37 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/grep-help/m-p/4467980#M360740</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2009-07-28T16:03:37Z</dc:date>
    </item>
    <item>
      <title>Re: grep help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/grep-help/m-p/4467981#M360741</link>
      <description>Hi:&lt;BR /&gt;&lt;BR /&gt;&amp;gt; Dennis: I'm not sure how these print out the previous 3 lines and the line with DEFAULT?&lt;BR /&gt;&lt;BR /&gt;They do _IF_ as the post suggests that the input file is composed of paragraphs with a blank line as the stanza seperator.&lt;BR /&gt;&lt;BR /&gt;Of course, that's my assumption and it would be obviously better if the OP had _attached_ the input.&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Tue, 28 Jul 2009 16:15:55 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/grep-help/m-p/4467981#M360741</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2009-07-28T16:15:55Z</dc:date>
    </item>
    <item>
      <title>Re: grep help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/grep-help/m-p/4467982#M360742</link>
      <description>Thanks for the Help but i am not getting the output as i want&lt;BR /&gt;&lt;BR /&gt;The attached is the input file.. they in paragraphs each of 4 lines each. &lt;BR /&gt;&lt;BR /&gt;Now i want the output to have all the paragraphs that have the word DEFAULT in it. &lt;BR /&gt;&lt;BR /&gt;Desired output &lt;BR /&gt;&lt;BR /&gt;checking kcrpw on inuap700&lt;BR /&gt;The Password Aging policy is ==&amp;gt; DEFAULT&lt;BR /&gt;The Account Life time  ==&amp;gt; NEVER EXPIRES&lt;BR /&gt;Number of unsuccesful logins Allowed ==&amp;gt;DEFAULT(6)&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;checking kcrpw on inuap705&lt;BR /&gt;The Password Aging policy is ==&amp;gt; DEFAULT&lt;BR /&gt;The Account Life time  ==&amp;gt; NEVER EXPIRES&lt;BR /&gt;Number of unsuccesful logins Allowed ==&amp;gt;DEFAULT(6)&lt;BR /&gt;&lt;BR /&gt;checking glprd on inuap706&lt;BR /&gt;The Password Aging policy is==&amp;gt;  DISABLED&lt;BR /&gt;The Account Life time  ==&amp;gt; NEVER EXPIRES&lt;BR /&gt;Number of unsuccesful logins Allowed ==&amp;gt;DEFAULT(6)&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;etc etc &lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Thanks a lot in advance&lt;BR /&gt;</description>
      <pubDate>Wed, 29 Jul 2009 03:47:05 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/grep-help/m-p/4467982#M360742</guid>
      <dc:creator>George Chechakunnil</dc:creator>
      <dc:date>2009-07-29T03:47:05Z</dc:date>
    </item>
    <item>
      <title>Re: grep help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/grep-help/m-p/4467983#M360743</link>
      <description>&lt;!--!*#--&gt;&amp;gt;The attached is the input file.  they are in paragraphs each of 4 lines each.&lt;BR /&gt;&lt;BR /&gt;Your input file doesn't have empty lines as separators, they have one space.&lt;BR /&gt;&lt;BR /&gt;You will have to change what was given to:&lt;BR /&gt;sed -e '/...*/{H;$!d;}' -e 'x;/DEFAULT/!d' file&lt;BR /&gt;&lt;BR /&gt;sed -e 's/^ *$//' file | awk '&lt;BR /&gt;BEGIN { RS=""}&lt;BR /&gt;/DEFAULT/ {print}'&lt;BR /&gt;&lt;BR /&gt;Or explicit programming for what's there:&lt;BR /&gt;awk '&lt;BR /&gt;/^checking / {&lt;BR /&gt;   getline l2; getline l3; getline l4&lt;BR /&gt;   if (l2 ~ /DEFAULT/ || l3 ~ /DEFAULT/ || l4 ~ /DEFAULT/) {&lt;BR /&gt;      print $0; print l2; print l3; print l4&lt;BR /&gt;   }&lt;BR /&gt;}' file&lt;BR /&gt;&lt;BR /&gt;&amp;gt;JRF: input file is composed of paragraphs with a blank line as the separator.&lt;BR /&gt;&lt;BR /&gt;I found the standard where it describes RS="".  It sure isn't on the man page.</description>
      <pubDate>Wed, 29 Jul 2009 05:23:38 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/grep-help/m-p/4467983#M360743</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2009-07-29T05:23:38Z</dc:date>
    </item>
    <item>
      <title>Re: grep help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/grep-help/m-p/4467984#M360744</link>
      <description>Terrific&lt;BR /&gt;&lt;BR /&gt;Thanks to all..&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Wed, 29 Jul 2009 08:28:56 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/grep-help/m-p/4467984#M360744</guid>
      <dc:creator>George Chechakunnil</dc:creator>
      <dc:date>2009-07-29T08:28:56Z</dc:date>
    </item>
    <item>
      <title>Re: grep help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/grep-help/m-p/4467985#M360745</link>
      <description>Although this post is too late, but I cannot help it.&lt;BR /&gt;sed -n -e ''/DEFAULT/'!{H;x;s/^.*\n\(.*\n.*\n.*\)$/\1/;x;}' -e ''/DEFAULT/'{H;x;p;}' File_Name</description>
      <pubDate>Fri, 31 Jul 2009 17:51:10 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/grep-help/m-p/4467985#M360745</guid>
      <dc:creator>Tingli</dc:creator>
      <dc:date>2009-07-31T17:51:10Z</dc:date>
    </item>
    <item>
      <title>Re: grep help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/grep-help/m-p/4467986#M360746</link>
      <description>Also too late, also redundant, but maybe helpful to someone some day as it is more 'open ended'.&lt;BR /&gt;&lt;BR /&gt;$ perl -ne 'if (/\S/)  { push @p,$_ } else {print @p if grep /DEFAULT/,@p; @p=("\n")}' x.txt&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;This looks for (arbitrary) paragraph markers, here a line with only whitespace.&lt;BR /&gt;&lt;BR /&gt;IF a line with non=whitespace is found, it is  pushed onto a paragraph array p.&lt;BR /&gt;ELSE the array p that was build up is grepped for a target (DEFAULT) and the whole array printed on match. The array is then reset to a single new-line for the next go around.&lt;BR /&gt;&lt;BR /&gt;btw... if there might not be a final paragraph marker, then you may want to turn it arouns some to catch a hit on the last paragraph:&lt;BR /&gt;&lt;BR /&gt;perl -ne '{ push @p,$_ } if (/^\s*$/ or eof) {print @p if grep /DEFAULT/,@p; @p=()}' a.txt&lt;BR /&gt;&lt;BR /&gt;fwiw,&lt;BR /&gt;Hein.&lt;BR /&gt;</description>
      <pubDate>Fri, 31 Jul 2009 19:00:11 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/grep-help/m-p/4467986#M360746</guid>
      <dc:creator>Hein van den Heuvel</dc:creator>
      <dc:date>2009-07-31T19:00:11Z</dc:date>
    </item>
    <item>
      <title>Re: grep help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/grep-help/m-p/4467987#M360747</link>
      <description>Hi (again):&lt;BR /&gt;&lt;BR /&gt;I just noticed this thread bubble to the top again.&lt;BR /&gt;&lt;BR /&gt;&amp;gt; Dennis: Your input file doesn't have empty lines as separators, they have one space.&lt;BR /&gt;&lt;BR /&gt;Ahh...now I see the reason for the confusion and the failure of my original suggestion to yield the output that George wanted [read on].&lt;BR /&gt;&lt;BR /&gt;&amp;gt; Dennis: I found the standard where it describes RS="".  It sure isn't on the man page.&lt;BR /&gt;&lt;BR /&gt;Ahh, yes, again!&lt;BR /&gt;&lt;BR /&gt;Based on the original post (before the attachment of text), it appeared to me that blank lines consisted solely of newline characters and these separated the stanzas or paragraphs.  My suggest was based upon that assumption.&lt;BR /&gt;&lt;BR /&gt;In Perl, when that is the case, if you set the record separator ('$/') to a null string, one or more blank lines constitute a record terminator.  Unfortunately, a "blanK line can consist only of a newline character without hidden spaces or tabs.  Perhaps more unfortunately, Perl doesn't allow a pattern in place of a simple string for the record separator.&lt;BR /&gt;&lt;BR /&gt;In the GNU 'awk' documentation, it is noted  that an empty string for the value of 'RS' signals that records are separated by one or more blank lines.  Dennis is correct; this _isn't_ described on the HP-UX manpages.  It works, though.&lt;BR /&gt;&lt;BR /&gt;Of my two original code snippets, I should have slightly modified the 'awk' variation to give back at least one blank line.  The Perl snippet could be better written for the way the Forum blends whitespace too:&lt;BR /&gt;&lt;BR /&gt;# perl -e '$/=qq();while (&amp;lt;&amp;gt;) {print if /DEFAULT/}' file&lt;BR /&gt;&lt;BR /&gt;or:&lt;BR /&gt;&lt;BR /&gt;# awk 'BEGIN{RS=""};/DEFAULT/ {print $0, "\n"}' file&lt;BR /&gt;&lt;BR /&gt;Finally, to filter your raw data so that it is suitable to being piped to either of the above snippets, you could do (for example):&lt;BR /&gt;&lt;BR /&gt;# perl -pe 's/^\s+$/\n/' file | perl -e 'BEGIN{$/=qq()};while (&amp;lt;&amp;gt;) {print if /DEFAULT/}'&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...&lt;BR /&gt;</description>
      <pubDate>Fri, 31 Jul 2009 20:09:11 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/grep-help/m-p/4467987#M360747</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2009-07-31T20:09:11Z</dc:date>
    </item>
  </channel>
</rss>

