<?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 in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-help/m-p/3163887#M903271</link>
    <description>Chris&lt;BR /&gt;&lt;BR /&gt;Still not clear.&lt;BR /&gt;From the example you just gave, after the first /4 K/, you want field 1 of the next line, then field 2 of the next line, field 2 of the next line, but then what ??&lt;BR /&gt;&lt;BR /&gt;The 2nd /4 K/ in your attachment is followed by "41490197 A", but your example is different.&lt;BR /&gt;&lt;BR /&gt;If you can give us the definitive rules, we can code it for you...&lt;BR /&gt;&lt;BR /&gt;-- Graham</description>
    <pubDate>Wed, 14 Jan 2004 11:30:37 GMT</pubDate>
    <dc:creator>Graham Cameron_1</dc:creator>
    <dc:date>2004-01-14T11:30:37Z</dc:date>
    <item>
      <title>AWK Help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-help/m-p/3163880#M903264</link>
      <description>Hi All,&lt;BR /&gt;&lt;BR /&gt;Is there a way that I can printf certain fields ($?), starting from (4 K) from file.&lt;BR /&gt;Currently I am using awk '{if($0~/4 K/){printf "\n%s %s\n",sep,$0;sep="\n";next}{printf "%s %s %s %s" ,$1,$5...etc , with no luck.&lt;BR /&gt;Any solutions will be appreciated.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Thanks&lt;BR /&gt;Chris&lt;BR /&gt;</description>
      <pubDate>Wed, 14 Jan 2004 05:41:24 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-help/m-p/3163880#M903264</guid>
      <dc:creator>Chris Frangandonis</dc:creator>
      <dc:date>2004-01-14T05:41:24Z</dc:date>
    </item>
    <item>
      <title>Re: AWK Help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-help/m-p/3163881#M903265</link>
      <description>Hi Chris, &lt;BR /&gt;    could you paste in a small extract of your file as I'm not sure what you want exactly.  Is 4 K on a line on it's own?  I tried opening the attachment but am not sure how it should really look.&lt;BR /&gt;    &lt;BR /&gt;    Mike</description>
      <pubDate>Wed, 14 Jan 2004 05:53:36 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-help/m-p/3163881#M903265</guid>
      <dc:creator>Mike Higgs</dc:creator>
      <dc:date>2004-01-14T05:53:36Z</dc:date>
    </item>
    <item>
      <title>Re: AWK Help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-help/m-p/3163882#M903266</link>
      <description>Hi Mike&lt;BR /&gt;&lt;BR /&gt;Thanks for you reply.&lt;BR /&gt;Here is the head of the text file&lt;BR /&gt;&lt;BR /&gt;&lt;AT 1.1="" lv="" 1.1="" nt="" 3.4.0.0=""&gt;D&lt;BR /&gt;808 h&lt;BR /&gt;J&lt;BR /&gt;808 g&lt;BR /&gt;b&lt;BR /&gt;J&lt;BR /&gt;4 K       &amp;lt;-------- is maybe my common piont&lt;BR /&gt;28295948 A     &amp;lt;------ Field 1&lt;BR /&gt;10 0123261078 A &amp;lt;----- Field 2&lt;BR /&gt;7 3070300 A&lt;BR /&gt;7 tpr+:09 E&lt;BR /&gt;1073920992 C&lt;BR /&gt;SL b&lt;BR /&gt;J&lt;BR /&gt;1 D&lt;BR /&gt;3 Q&lt;BR /&gt;&lt;BR /&gt;etc........&lt;BR /&gt;&lt;BR /&gt;Thanks&lt;BR /&gt;Chris&lt;BR /&gt;&lt;/AT&gt;</description>
      <pubDate>Wed, 14 Jan 2004 06:00:26 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-help/m-p/3163882#M903266</guid>
      <dc:creator>Chris Frangandonis</dc:creator>
      <dc:date>2004-01-14T06:00:26Z</dc:date>
    </item>
    <item>
      <title>Re: AWK Help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-help/m-p/3163883#M903267</link>
      <description>awk '/4K/{getline;print;getline;print}' filename&lt;BR /&gt;</description>
      <pubDate>Wed, 14 Jan 2004 06:18:36 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-help/m-p/3163883#M903267</guid>
      <dc:creator>Steve Lewis</dc:creator>
      <dc:date>2004-01-14T06:18:36Z</dc:date>
    </item>
    <item>
      <title>Re: AWK Help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-help/m-p/3163884#M903268</link>
      <description>Chris&lt;BR /&gt;Not sure what you mean because first you talk about fields but then in your later example you are really talking lines.&lt;BR /&gt;&lt;BR /&gt;Steve's post will print the next 2 lines after each time it finds the string /4K/, (except I think you wanted a space -ie /4 K/) because getline gets the next line, and print with no arguments prints the entire line (as does print $0).&lt;BR /&gt;&lt;BR /&gt;If you want to operate on fields within lines, that's when to use $1, $2 etc, up to $NF.&lt;BR /&gt;&lt;BR /&gt;So, if you wanted to print the 2nd field of the line after /4 K/. and the 3rd and 4th fields of the line after that:&lt;BR /&gt;&lt;BR /&gt;awk '&lt;BR /&gt;/4 K/ {next; printf ("%s\n", $2);next; printf ("%s %s\n", $3, $4) }&lt;BR /&gt;'&lt;BR /&gt;&lt;BR /&gt;Semicolons are needed to separate commands on the same line, but if you put them on separate lines you don't need them.&lt;BR /&gt;&lt;BR /&gt;Hope this helps&lt;BR /&gt;&lt;BR /&gt;-- Graham</description>
      <pubDate>Wed, 14 Jan 2004 07:22:17 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-help/m-p/3163884#M903268</guid>
      <dc:creator>Graham Cameron_1</dc:creator>
      <dc:date>2004-01-14T07:22:17Z</dc:date>
    </item>
    <item>
      <title>Re: AWK Help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-help/m-p/3163885#M903269</link>
      <description>So, do you want fields from the two lines following the "4 K" line?&lt;BR /&gt;&lt;BR /&gt;Mike</description>
      <pubDate>Wed, 14 Jan 2004 07:59:59 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-help/m-p/3163885#M903269</guid>
      <dc:creator>Mike Higgs</dc:creator>
      <dc:date>2004-01-14T07:59:59Z</dc:date>
    </item>
    <item>
      <title>Re: AWK Help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-help/m-p/3163886#M903270</link>
      <description>Hi All,&lt;BR /&gt;&lt;BR /&gt;Thanks once again.&lt;BR /&gt;&lt;BR /&gt;Mike/Steve/Graham)I want to be able to select any fields after the first /4 K/ and the next /4 K/ and so on until EOF&lt;BR /&gt;&lt;BR /&gt;The End result should look like this from the text file supplied.&lt;BR /&gt;&lt;BR /&gt;1)28295948 0123261078 3070300 tpr+:09 1073920992 .. .. etc&lt;BR /&gt;2)75804243 0137411100 0137534401 tnpt:03 &lt;BR /&gt;1073942316 .. .. etc&lt;BR /&gt;3)55491852  .. .. .. .. etc&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Hope this helps.&lt;BR /&gt;&lt;BR /&gt;Thanks&lt;BR /&gt;Chris&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Wed, 14 Jan 2004 08:37:04 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-help/m-p/3163886#M903270</guid>
      <dc:creator>Chris Frangandonis</dc:creator>
      <dc:date>2004-01-14T08:37:04Z</dc:date>
    </item>
    <item>
      <title>Re: AWK Help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-help/m-p/3163887#M903271</link>
      <description>Chris&lt;BR /&gt;&lt;BR /&gt;Still not clear.&lt;BR /&gt;From the example you just gave, after the first /4 K/, you want field 1 of the next line, then field 2 of the next line, field 2 of the next line, but then what ??&lt;BR /&gt;&lt;BR /&gt;The 2nd /4 K/ in your attachment is followed by "41490197 A", but your example is different.&lt;BR /&gt;&lt;BR /&gt;If you can give us the definitive rules, we can code it for you...&lt;BR /&gt;&lt;BR /&gt;-- Graham</description>
      <pubDate>Wed, 14 Jan 2004 11:30:37 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-help/m-p/3163887#M903271</guid>
      <dc:creator>Graham Cameron_1</dc:creator>
      <dc:date>2004-01-14T11:30:37Z</dc:date>
    </item>
    <item>
      <title>Re: AWK Help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-help/m-p/3163888#M903272</link>
      <description>Graham,&lt;BR /&gt;&lt;BR /&gt;Your are correct. I missed a line and yes  What I am trying to achieve is, after the /4 K/ is found line up the fields if possible(see attachment), use printf for whatever field, look for the next /4 K/ and repeat the steps as above, until EOF.&lt;BR /&gt;&lt;BR /&gt;Hope this makes sense.&lt;BR /&gt;&lt;BR /&gt;Thanks Once Again&lt;BR /&gt;Chris&lt;BR /&gt;</description>
      <pubDate>Wed, 14 Jan 2004 12:39:31 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-help/m-p/3163888#M903272</guid>
      <dc:creator>Chris Frangandonis</dc:creator>
      <dc:date>2004-01-14T12:39:31Z</dc:date>
    </item>
    <item>
      <title>Re: AWK Help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-help/m-p/3163889#M903273</link>
      <description>Awk, he sed.....&lt;BR /&gt;&lt;BR /&gt;Wot's wrong, Chris, can't you program....&lt;BR /&gt;&lt;BR /&gt;(sorry chaps, private joke between me and Fandango....)</description>
      <pubDate>Thu, 15 Jan 2004 01:28:13 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-help/m-p/3163889#M903273</guid>
      <dc:creator>Jakes Louw</dc:creator>
      <dc:date>2004-01-15T01:28:13Z</dc:date>
    </item>
    <item>
      <title>Re: AWK Help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-help/m-p/3163890#M903274</link>
      <description>It would be something like this then:&lt;BR /&gt;awk '/4 K/ { getline; printf "%s",$1; getline; printf " %s\n",$2}'&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Or do you mean this:&lt;BR /&gt;awk '/4 K/ { getline; printf "%s",$0; getline; printf" %s\n",$0}'&lt;BR /&gt;&lt;BR /&gt;You can change the printf statements to whatever you like, of course. The getline will just replace all argument fields...&lt;BR /&gt;</description>
      <pubDate>Thu, 15 Jan 2004 02:36:15 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-help/m-p/3163890#M903274</guid>
      <dc:creator>Elmar P. Kolkman</dc:creator>
      <dc:date>2004-01-15T02:36:15Z</dc:date>
    </item>
    <item>
      <title>Re: AWK Help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-help/m-p/3163891#M903275</link>
      <description>Hi Elmar,&lt;BR /&gt;&lt;BR /&gt;Thanks for your reply.&lt;BR /&gt;&lt;BR /&gt;By doining { getline; printf "%s",$0;getline; printf" %s\n",$0}', your are getting the next two fields which is not what I am looking for. I must be able to select any fields after /4 K/. &lt;BR /&gt;&lt;BR /&gt;Thanks Chris&lt;BR /&gt;</description>
      <pubDate>Thu, 15 Jan 2004 03:27:53 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-help/m-p/3163891#M903275</guid>
      <dc:creator>Chris Frangandonis</dc:creator>
      <dc:date>2004-01-15T03:27:53Z</dc:date>
    </item>
    <item>
      <title>Re: AWK Help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-help/m-p/3163892#M903276</link>
      <description>What do you mean any field?!&lt;BR /&gt;&lt;BR /&gt;Do you mean something like this then?&lt;BR /&gt;&lt;BR /&gt;awk 'BEGIN {field=""}&lt;BR /&gt;/4 K/ if (field != "") { &lt;DO your="" stuff="" with="" the="" content="" of="" field=""&gt; ; field="";next;}&lt;BR /&gt;{field = field + $0 }&lt;BR /&gt;END { &lt;DO your="" stuff="" with="" the="" content="" of="" field=""&gt; }'&lt;BR /&gt;&lt;BR /&gt;This will get the lines between '4 K' records into the field var. You can do with that what you want then.&lt;/DO&gt;&lt;/DO&gt;</description>
      <pubDate>Thu, 15 Jan 2004 08:15:02 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-help/m-p/3163892#M903276</guid>
      <dc:creator>Elmar P. Kolkman</dc:creator>
      <dc:date>2004-01-15T08:15:02Z</dc:date>
    </item>
    <item>
      <title>Re: AWK Help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-help/m-p/3163893#M903277</link>
      <description>Elmar,&lt;BR /&gt;&lt;BR /&gt;What I mean is that when /4 K/ is found, from awk '{if($0~/4 K/){printf "\n%s %s\n",sep,$0;sep="\n";next}{printf "%s" ,$0}| awk '{print $5,$15,$16}' it returns an error "cannot be longer than 3000 bytes.&lt;BR /&gt;&lt;BR /&gt;If you look at the attachment you will see that the lines a quit long. As for the result, I would like to see the output as:&lt;BR /&gt;&lt;BR /&gt;(after the first /4 K/ )&lt;BR /&gt;0123268282 20040112180457 0123070300 41490197 I ds09 tpr+:09 tpr+:09.ds09.0000289.00017900.20040112220000 &lt;BR /&gt;(after the next /4 K/)&lt;BR /&gt;0145381447 20040112233314 0860007249  55491852  B ds09 trt+:03 trt+:03.ds09.0000022.00017970.20040113044000 &lt;BR /&gt;(after the next /4 K/)&lt;BR /&gt;0137412701 20040112221150 ........etc.&lt;BR /&gt;&lt;BR /&gt;I may choose futher more fields, for the above is an example.&lt;BR /&gt;&lt;BR /&gt;If you have a better solution please post it.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Thanks&lt;BR /&gt;Chris&lt;BR /&gt;&lt;BR /&gt;Hope this helps&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 15 Jan 2004 09:09:16 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-help/m-p/3163893#M903277</guid>
      <dc:creator>Chris Frangandonis</dc:creator>
      <dc:date>2004-01-15T09:09:16Z</dc:date>
    </item>
    <item>
      <title>Re: AWK Help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-help/m-p/3163894#M903278</link>
      <description>The attachment you provided in the recent post is different from your first.&lt;BR /&gt; &lt;BR /&gt;Also the example you display doesn't match up with the line after the first /4 K/, but maybe the second /4 K/.&lt;BR /&gt; &lt;BR /&gt;If the fields do exist on each line, why couldn't you use "cut" to select the fields you want?&lt;BR /&gt; &lt;BR /&gt;example-&lt;BR /&gt;cut -f 12,18,24 &lt;YOURINPUT&gt;youroutput&lt;BR /&gt; &lt;BR /&gt;This would allow you to select the fields you want.&lt;BR /&gt; &lt;BR /&gt;If the first file you attached represents the true data, then a tool like "perl" could be used to slurp up the data, organize it, then print out the arrangement you want.&lt;BR /&gt; &lt;BR /&gt;Your definition of the problem is very hard to follow...&lt;BR /&gt; &lt;BR /&gt;-- Rod Hills&lt;/YOURINPUT&gt;</description>
      <pubDate>Thu, 15 Jan 2004 10:46:30 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-help/m-p/3163894#M903278</guid>
      <dc:creator>Rodney Hills</dc:creator>
      <dc:date>2004-01-15T10:46:30Z</dc:date>
    </item>
    <item>
      <title>Re: AWK Help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-help/m-p/3163895#M903279</link>
      <description>Tried to reply yesterday, but had problems contacting the forums.&lt;BR /&gt;&lt;BR /&gt;To solve your problem, put the fields between the '4 K' lines in an array and use that to select the fields. But first check if awk can work with the input file. You can do this like this:&lt;BR /&gt;cat datafile | awk '{print $1}' &amp;gt; /dev/null&lt;BR /&gt;&lt;BR /&gt;It might fail, which means awk might be useless (don't see options to use longer recordlength) and you might consider perl.&lt;BR /&gt;&lt;BR /&gt;If that succeeds, your script will become something like this:&lt;BR /&gt;awk '/4 K/ { if (idx &amp;gt; 0) {&lt;BR /&gt;   printf ("$s $s $s $s\n",fields[1],fields[5],fields[6],fields[15]);&lt;BR /&gt;      while (idx &amp;gt; 0) {&lt;BR /&gt;         fields[idx]="";&lt;BR /&gt;         idx--;&lt;BR /&gt;      }&lt;BR /&gt;   }&lt;BR /&gt;   printf("4 K\n");&lt;BR /&gt;   started=1;&lt;BR /&gt;  }&lt;BR /&gt;{ if (started) {&lt;BR /&gt;    i=0;&lt;BR /&gt;    while (i &amp;lt; NF) {&lt;BR /&gt;       idx++;&lt;BR /&gt;       i++;&lt;BR /&gt;       fields[idx]=$i&lt;BR /&gt;    }&lt;BR /&gt;  }&lt;BR /&gt;}'</description>
      <pubDate>Fri, 16 Jan 2004 01:36:00 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-help/m-p/3163895#M903279</guid>
      <dc:creator>Elmar P. Kolkman</dc:creator>
      <dc:date>2004-01-16T01:36:00Z</dc:date>
    </item>
  </channel>
</rss>

