<?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 help again in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-help-again/m-p/2954220#M720163</link>
    <description>Jim Ferguson, thanks a lot, I am getting exactly what I am looking for with a little tweaking.  &lt;BR /&gt;&lt;BR /&gt;As always guys thanks for all the responses, comic including and for your efforts and see you at the next request</description>
    <pubDate>Fri, 18 Apr 2003 13:48:23 GMT</pubDate>
    <dc:creator>Belinda Dermody</dc:creator>
    <dc:date>2003-04-18T13:48:23Z</dc:date>
    <item>
      <title>Awk help again</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-help-again/m-p/2954200#M720143</link>
      <description>I have a maillog like below, one entry from a couple hundred thousand per day.  Each line starts with a date time stamp.   All I want from the log is grab the HeaderTo= &lt;FOR a="" specified="" name=""&gt; and the line before which is HeaderFrom and the line after HeaderSubject&lt;BR /&gt;&lt;BR /&gt;Apr 17 03:11:29 guadeloupe smap[15162]: ACCEPTING MESSAGE - INFORMATION FOLLOWS&lt;BR /&gt;Apr 17 03:11:29 guadeloupe smap[15162]: HeaderFrom='"ZZZZZ YYYYYY" &lt;XXXXXX&gt;&lt;/XXXXXX&gt;acoast.com&amp;gt;'&lt;BR /&gt;Apr 17 03:11:29 guadeloupe smap[15162]: HeaderTo='&lt;XXXXXXXX&gt;'&lt;BR /&gt;Apr 17 03:11:29 guadeloupe smap[15162]: HeaderSubject='Your Perfect Home - New L&lt;BR /&gt;istings for 4/17/2003'&lt;BR /&gt;Apr 17 03:11:29 guadeloupe smap[15162]: SMTP HostName='smtp.onlinehelp.com'&lt;BR /&gt;Apr 17 03:11:29 guadeloupe smap[15162]: SMTP IPAddress='99.9999.999.99'&lt;BR /&gt;Apr 17 03:11:29 guadeloupe smap[15162]: SMTP HELO='smtp.onlinehelp.com'&lt;BR /&gt;Apr 17 03:11:29 guadeloupe smap[15162]: SMTP MAIL From='ZZZZZZZZ@Seacoast.com'&lt;BR /&gt;&lt;/XXXXXXXX&gt;&lt;/FOR&gt;</description>
      <pubDate>Thu, 17 Apr 2003 16:48:59 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-help-again/m-p/2954200#M720143</guid>
      <dc:creator>Belinda Dermody</dc:creator>
      <dc:date>2003-04-17T16:48:59Z</dc:date>
    </item>
    <item>
      <title>Re: Awk help again</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-help-again/m-p/2954201#M720144</link>
      <description>James,&lt;BR /&gt;&lt;BR /&gt;How about something like this, with grep, instead:&lt;BR /&gt;&lt;BR /&gt;# print 1 line of context before and after regexp, with line number&lt;BR /&gt; # indicating where the regexp occurred (similar to "grep -A1 -B1")&lt;BR /&gt; sed -n -e '/regexp/{=;x;1!p;g;$!N;p;D;}' -e h&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Pete</description>
      <pubDate>Thu, 17 Apr 2003 16:54:17 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-help-again/m-p/2954201#M720144</guid>
      <dc:creator>Pete Randall</dc:creator>
      <dc:date>2003-04-17T16:54:17Z</dc:date>
    </item>
    <item>
      <title>Re: Awk help again</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-help-again/m-p/2954202#M720145</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;Fleet Fingered Pete has given you a solution in sed [I love those sed one liners!].  Here is a little Perl snippet that might work:&lt;BR /&gt;&lt;BR /&gt;perl -ne 'print if /HeaderFrom/ .. /HeaderSubject/' maillog&lt;BR /&gt;&lt;BR /&gt;JP&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 17 Apr 2003 17:26:37 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-help-again/m-p/2954202#M720145</guid>
      <dc:creator>John Poff</dc:creator>
      <dc:date>2003-04-17T17:26:37Z</dc:date>
    </item>
    <item>
      <title>Re: Awk help again</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-help-again/m-p/2954203#M720146</link>
      <description>Hi James:&lt;BR /&gt;&lt;BR /&gt;Yet another (this time in 'awk'):&lt;BR /&gt;&lt;BR /&gt;# WHO=james&lt;BR /&gt;# awk -v WHO=$WHO '/HeaderFrom=/ &amp;amp;&amp;amp; $0~WHO,/HeaderSubject=/ {print $0}' filename&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Thu, 17 Apr 2003 18:01:57 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-help-again/m-p/2954203#M720146</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2003-04-17T18:01:57Z</dc:date>
    </item>
    <item>
      <title>Re: Awk help again</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-help-again/m-p/2954204#M720147</link>
      <description>Pete, you almost got it, but the trouble is&lt;BR /&gt;I want the three lines that are HeaderTo, HeaderFrom and HeaderSubject.  &lt;BR /&gt;&lt;BR /&gt;The key is on HeaderTo for the regexp.  Sometimes it is&lt;BR /&gt;HeaderTo='&lt;ADDRESS&gt;'&lt;BR /&gt;or&lt;BR /&gt;HeaderTo='address'&lt;BR /&gt;&lt;BR /&gt;any clues&lt;/ADDRESS&gt;</description>
      <pubDate>Thu, 17 Apr 2003 18:36:49 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-help-again/m-p/2954204#M720147</guid>
      <dc:creator>Belinda Dermody</dc:creator>
      <dc:date>2003-04-17T18:36:49Z</dc:date>
    </item>
    <item>
      <title>Re: Awk help again</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-help-again/m-p/2954205#M720148</link>
      <description>James Ferguson, you are the same.  I need to key in on the &lt;BR /&gt;HeaderTo and then grab the line before and the line after.  &lt;BR /&gt;&lt;BR /&gt;The problem is the HeaderTo could be either&lt;BR /&gt;HeaderTo='&lt;ADDRESS&gt;'&lt;BR /&gt;or&lt;BR /&gt;HeaderTo='address'&lt;/ADDRESS&gt;</description>
      <pubDate>Thu, 17 Apr 2003 18:39:24 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-help-again/m-p/2954205#M720148</guid>
      <dc:creator>Belinda Dermody</dc:creator>
      <dc:date>2003-04-17T18:39:24Z</dc:date>
    </item>
    <item>
      <title>Re: Awk help again</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-help-again/m-p/2954206#M720149</link>
      <description>of course you could always hire an attractive "administrative assistant" and have her pull these lines out by hand while you practice your awk skills  :)&lt;BR /&gt;&lt;BR /&gt;Sorry... it's been a looooon week with a 19 hour planned outage this past saturday.... i needed the humor</description>
      <pubDate>Thu, 17 Apr 2003 18:43:45 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-help-again/m-p/2954206#M720149</guid>
      <dc:creator>John Meissner</dc:creator>
      <dc:date>2003-04-17T18:43:45Z</dc:date>
    </item>
    <item>
      <title>Re: Awk help again</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-help-again/m-p/2954207#M720150</link>
      <description>John I have been practicing my awk skills, I have a habit of trying many different ways and have been working on this since Monday, so I decided to come to the experts, which I guess your field is comedy...</description>
      <pubDate>Thu, 17 Apr 2003 18:47:58 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-help-again/m-p/2954207#M720150</guid>
      <dc:creator>Belinda Dermody</dc:creator>
      <dc:date>2003-04-17T18:47:58Z</dc:date>
    </item>
    <item>
      <title>Re: Awk help again</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-help-again/m-p/2954208#M720151</link>
      <description>James - I'm not busting on your skills.  I have actually tried to figure this type of problem out myslef (stripping out a range in awk &amp;amp; sed) but I don't think i've been that successful in the past.  I usually found other ways around this.  in order to get a range in sed you can &lt;BR /&gt;sed 's/beginning/,/end/g' &lt;BR /&gt;</description>
      <pubDate>Thu, 17 Apr 2003 18:51:29 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-help-again/m-p/2954208#M720151</guid>
      <dc:creator>John Meissner</dc:creator>
      <dc:date>2003-04-17T18:51:29Z</dc:date>
    </item>
    <item>
      <title>Re: Awk help again</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-help-again/m-p/2954209#M720152</link>
      <description>James,&lt;BR /&gt;&lt;BR /&gt;Is the name you are looking for an e-mail address in the form of somename@somedomain.com, or are you just looking for somename? Does the HeaderTo= always have single quotes around the name?  &lt;BR /&gt;&lt;BR /&gt;The Perl example I gave doesn't look for the name at all.  I'll try that again.&lt;BR /&gt;&lt;BR /&gt;JP&lt;BR /&gt;</description>
      <pubDate>Thu, 17 Apr 2003 18:52:13 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-help-again/m-p/2954209#M720152</guid>
      <dc:creator>John Poff</dc:creator>
      <dc:date>2003-04-17T18:52:13Z</dc:date>
    </item>
    <item>
      <title>Re: Awk help again</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-help-again/m-p/2954210#M720153</link>
      <description>and out of all my post - I think that was my second attempt at humor.... i'll keep practicing  :)</description>
      <pubDate>Thu, 17 Apr 2003 18:53:06 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-help-again/m-p/2954210#M720153</guid>
      <dc:creator>John Meissner</dc:creator>
      <dc:date>2003-04-17T18:53:06Z</dc:date>
    </item>
    <item>
      <title>Re: Awk help again</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-help-again/m-p/2954211#M720154</link>
      <description>How about this-&lt;BR /&gt;&lt;BR /&gt;awk '/HeaderTo=/{ print prev; print $0; getline ; print $0; }/;{prev=$0}' maillog&lt;BR /&gt;&lt;BR /&gt;This will hold the line before in "prev", when HeaderTo is found prev and current line is printed. Then a "getline" reads the next line and prints it.&lt;BR /&gt;&lt;BR /&gt;HTH&lt;BR /&gt;&lt;BR /&gt;-- Rod Hills</description>
      <pubDate>Thu, 17 Apr 2003 20:06:17 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-help-again/m-p/2954211#M720154</guid>
      <dc:creator>Rodney Hills</dc:creator>
      <dc:date>2003-04-17T20:06:17Z</dc:date>
    </item>
    <item>
      <title>Re: Awk help again</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-help-again/m-p/2954212#M720155</link>
      <description>Hi (again) James:&lt;BR /&gt;&lt;BR /&gt;OK, try this:&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;awk -v WHO="HeaderTo=$1" '&lt;BR /&gt;  { if ( $0~WHO ) {print LINE;print $0;getline;print $0} else {LINE=$0}&lt;BR /&gt;  }' filename&lt;BR /&gt;exit 0&lt;BR /&gt;&lt;BR /&gt;...pass the argument to match the string that follows "HeaderTo=".  Thus if the script were called 'my.sh' do:&lt;BR /&gt;&lt;BR /&gt;# my.sh "'&lt;JAMES&gt;"&lt;BR /&gt;&lt;BR /&gt;...or:&lt;BR /&gt;&lt;BR /&gt;# mysh "james"&lt;BR /&gt;&lt;BR /&gt;...etc., depending on the string following the equal sign.&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...&lt;BR /&gt;&lt;/JAMES&gt;</description>
      <pubDate>Thu, 17 Apr 2003 20:25:23 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-help-again/m-p/2954212#M720155</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2003-04-17T20:25:23Z</dc:date>
    </item>
    <item>
      <title>Re: Awk help again</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-help-again/m-p/2954213#M720156</link>
      <description>Hi James,&lt;BR /&gt;I attach you a couple of scripts, with the first one the address is embeded in the script itself, in the second one you must type the address in the command line.&lt;BR /&gt;&lt;BR /&gt;- First script.&lt;BR /&gt;&lt;BR /&gt;awk -f file.awk inputfile &amp;gt; outputfile&lt;BR /&gt;&lt;BR /&gt;- Second script&lt;BR /&gt;&lt;BR /&gt;awk -v address="XXXXXXXX@alum\\.colby\\.edu" -f file2.awk inputfile &amp;gt; outputfile&lt;BR /&gt;&lt;BR /&gt;hope this helps.&lt;BR /&gt;&lt;BR /&gt;Frank.</description>
      <pubDate>Thu, 17 Apr 2003 21:18:31 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-help-again/m-p/2954213#M720156</guid>
      <dc:creator>Francisco J. Soler</dc:creator>
      <dc:date>2003-04-17T21:18:31Z</dc:date>
    </item>
    <item>
      <title>Re: Awk help again</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-help-again/m-p/2954214#M720157</link>
      <description>Sorry James,&lt;BR /&gt;&lt;BR /&gt;While I will always think that the forums are the greatest resource there is, I'm supposed to be starting my vacation (and Momma said NOW!).  I would attach all the "Handy One Liners for Sed" that Princess Paula originally posted so you might be able to noodle through - but I'm at home, I can't get to my notes - AND MOMMA SAYS NOW!!!&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Pete</description>
      <pubDate>Thu, 17 Apr 2003 22:26:35 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-help-again/m-p/2954214#M720157</guid>
      <dc:creator>Pete Randall</dc:creator>
      <dc:date>2003-04-17T22:26:35Z</dc:date>
    </item>
    <item>
      <title>Re: Awk help again</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-help-again/m-p/2954215#M720158</link>
      <description>Pete,&lt;BR /&gt;&lt;BR /&gt;I've got you covered.  I keep my sed one liners handy at work.  I'm at home now, but I found a recent copy from the author's web page.  I've posted it as an attachment.&lt;BR /&gt;&lt;BR /&gt;JP&lt;BR /&gt;&lt;BR /&gt;P.S.  I understand what it means when Momma says NOW!  Enjoy your vacation.  :)&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Fri, 18 Apr 2003 00:01:49 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-help-again/m-p/2954215#M720158</guid>
      <dc:creator>John Poff</dc:creator>
      <dc:date>2003-04-18T00:01:49Z</dc:date>
    </item>
    <item>
      <title>Re: Awk help again</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-help-again/m-p/2954216#M720159</link>
      <description>Thanks, John!&lt;BR /&gt;&lt;BR /&gt;I knew someone would pick up the slack.  I'll send you a post card!&lt;BR /&gt;&lt;BR /&gt;Pete</description>
      <pubDate>Fri, 18 Apr 2003 00:20:02 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-help-again/m-p/2954216#M720159</guid>
      <dc:creator>Pete Randall</dc:creator>
      <dc:date>2003-04-18T00:20:02Z</dc:date>
    </item>
    <item>
      <title>Re: Awk help again</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-help-again/m-p/2954217#M720160</link>
      <description>Thanks to all you guy's, I haven't tried all the new responses yet, but that is why I have always insisted to my manager to make sure whatever support we have for our HP system that I have the forum option available.  I very seldom call any longer, The response from the site (might be slow getting to it from the internet once in a while) is the greatest and the best and the diversacation of answers and abilities are the best and I have responded that to the leaders anumber of times.  &lt;BR /&gt;&lt;BR /&gt;We support online communities for Universities and Orgs and one of our perks is a email forwarding capabilities and of course the upper management like daily numbers and stats.&lt;BR /&gt;the To address could have ' ' around the address or &amp;lt; &amp;gt; or '&amp;lt; &amp;gt;' so I would just like to grab the address within the special chars.</description>
      <pubDate>Fri, 18 Apr 2003 11:52:52 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-help-again/m-p/2954217#M720160</guid>
      <dc:creator>Belinda Dermody</dc:creator>
      <dc:date>2003-04-18T11:52:52Z</dc:date>
    </item>
    <item>
      <title>Re: Awk help again</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-help-again/m-p/2954218#M720161</link>
      <description>Hi (again) James:&lt;BR /&gt;&lt;BR /&gt;Based on your last comments, if you could find the lines you want regardless of how they are bounded, using the script I supplied, thusly:&lt;BR /&gt;&lt;BR /&gt;# my.sh "'*&amp;lt;*James&amp;gt;*'*"&lt;BR /&gt;&lt;BR /&gt;...would return matches for:&lt;BR /&gt;&lt;BR /&gt;HeaderTo=James&lt;BR /&gt;HeaderTo=&lt;JAMES&gt;&lt;BR /&gt;HeaderTo='&lt;JAMES&gt;'&lt;BR /&gt;HeaderTo='James'&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...&lt;/JAMES&gt;&lt;/JAMES&gt;</description>
      <pubDate>Fri, 18 Apr 2003 12:18:56 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-help-again/m-p/2954218#M720161</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2003-04-18T12:18:56Z</dc:date>
    </item>
    <item>
      <title>Re: Awk help again</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-help-again/m-p/2954219#M720162</link>
      <description>Hi (again) James:&lt;BR /&gt;&lt;BR /&gt;Since you're filtering mail logs, perhaps you like to extract (match) names case-insensitively, so that "James" is the same as "james".  If so try this script with your data:&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;typeset -l  WHO="HeaderTo='*&amp;lt;*${1}&amp;gt;*'*"&lt;BR /&gt;awk -v WHO=$WHO '&lt;BR /&gt;  { if (tolower($0)~WHO) {print LINE;print $0;getline;print $0} else {LINE=$0}&lt;BR /&gt;  }' filename&lt;BR /&gt;exit 0&lt;BR /&gt;&lt;BR /&gt;...now to extract any variation of "jAmEs":&lt;BR /&gt;&lt;BR /&gt;./my.sh jAmEs&lt;BR /&gt;&lt;BR /&gt;Note that you pass one argument representing the name to match.&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Fri, 18 Apr 2003 13:14:17 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-help-again/m-p/2954219#M720162</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2003-04-18T13:14:17Z</dc:date>
    </item>
  </channel>
</rss>

