<?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 - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-problem/m-p/2770764#M942425</link>
    <description>The attachment you provided can not be opened because it is binary. Process the file through uuencode and attach that resultant file.&lt;BR /&gt;&lt;BR /&gt;-- Rod Hills</description>
    <pubDate>Thu, 25 Jul 2002 20:36:46 GMT</pubDate>
    <dc:creator>Rodney Hills</dc:creator>
    <dc:date>2002-07-25T20:36:46Z</dc:date>
    <item>
      <title>Awk Problem</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-problem/m-p/2770741#M942402</link>
      <description>Hi All,&lt;BR /&gt;&lt;BR /&gt;I have a file in hex which looks as follows :&lt;BR /&gt;&lt;BR /&gt;0000000 4844 5231 6466 3233 4241 4430 3232 3030&lt;BR /&gt;0000010 0800 4040 07fc 0000 c6c4 8472 1002 0200&lt;BR /&gt;0000020 2211 1500 0000 0000 00ff ff02 4040 4040&lt;BR /&gt;0000030 4040 4040 4040 4040 0100 2601 1101 0200&lt;BR /&gt;0000040 1755 2400 003a 0000 0103 ff02 0102 0209&lt;BR /&gt;0000050 010a 0103 2191 3256 8f05 0601 0293 0471&lt;BR /&gt;0000060 1f01 0027 0111 0102 0017 5527 0001 7400&lt;BR /&gt;0000070 0002 03ff 0201 0202 0901 0f01 0321 9053&lt;BR /&gt;0000080 227f 0507 0102 0114 2442 9501 0027 0111&lt;BR /&gt;0000090 0102 0017 5527 0002 eb00 0004 03ff 0201&lt;BR /&gt;00000a0 0202 0901 0a01 0321 9512 584f 0507 0102&lt;BR /&gt;00000b0 0837 4651 9901 0027 0111 0102 0017 5528&lt;BR /&gt;00000c0 0001 2000 0000 03ff 0201 0202 0901 0f01&lt;BR /&gt;00000d0 0321 9020 005f 0507 0102 0800 0068 7001&lt;BR /&gt;&lt;BR /&gt;By using the awk command or any other, I would the output to be in separate lines for eg:&lt;BR /&gt;&lt;BR /&gt;0100 2601 1101 0200 1755 2400 1755 2400 003a 0000 0103 ff02 0102 0209 010a 0103 2191 3256 8f05 0601 0293 0471 1f01 &lt;BR /&gt;01 0027 0111 0102 0017 5527 0001 7400 0002 03ff 0201 0202 0901 0f01 0321 9053 227f 0507 0102 0114 2442 95&lt;BR /&gt;01 0027 0111 etc.....  &lt;BR /&gt;The first coloum ($1)  should not appear.&lt;BR /&gt;&lt;BR /&gt;Kind Regards&lt;BR /&gt;Chris&lt;BR /&gt;</description>
      <pubDate>Tue, 23 Jul 2002 18:45:43 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-problem/m-p/2770741#M942402</guid>
      <dc:creator>Chris Frangandonis</dc:creator>
      <dc:date>2002-07-23T18:45:43Z</dc:date>
    </item>
    <item>
      <title>Re: Awk Problem</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-problem/m-p/2770742#M942403</link>
      <description>This should work:&lt;BR /&gt;&lt;BR /&gt;# cut -d" " -f2-9 input_file&lt;BR /&gt;&lt;BR /&gt;Assuming that there are 9 fields per line with a single space as delimiter between any two fields.&lt;BR /&gt;&lt;BR /&gt;Hai</description>
      <pubDate>Tue, 23 Jul 2002 18:55:28 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-problem/m-p/2770742#M942403</guid>
      <dc:creator>Hai Nguyen_1</dc:creator>
      <dc:date>2002-07-23T18:55:28Z</dc:date>
    </item>
    <item>
      <title>Re: Awk Problem</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-problem/m-p/2770743#M942404</link>
      <description>Hi Chris:&lt;BR /&gt;&lt;BR /&gt;If you want to drop the first field of every record, outputting the remainder, you could do:&lt;BR /&gt;&lt;BR /&gt;# awk '{for (i=2;i&lt;NF&gt;&lt;/NF&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Tue, 23 Jul 2002 18:58:48 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-problem/m-p/2770743#M942404</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2002-07-23T18:58:48Z</dc:date>
    </item>
    <item>
      <title>Re: Awk Problem</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-problem/m-p/2770744#M942405</link>
      <description>With the "cut" solution, you can just use.&lt;BR /&gt;cut -d" " -f2-&lt;BR /&gt;&lt;BR /&gt;This will not limit you to 9 fields.&lt;BR /&gt;</description>
      <pubDate>Tue, 23 Jul 2002 19:04:22 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-problem/m-p/2770744#M942405</guid>
      <dc:creator>Rich Wright</dc:creator>
      <dc:date>2002-07-23T19:04:22Z</dc:date>
    </item>
    <item>
      <title>Re: Awk Problem</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-problem/m-p/2770745#M942406</link>
      <description>The various solutiopn will work but you seem to front-ending the file with od. You must do that because cut, awk, sed, etc. will not be able to handle input that is not LF delimted.&lt;BR /&gt;&lt;BR /&gt;I assume that you have chosen the desired -t x conversion. I also suggest that you use od -v so that repeated lines are displayed explicitly.&lt;BR /&gt;</description>
      <pubDate>Tue, 23 Jul 2002 19:10:35 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-problem/m-p/2770745#M942406</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2002-07-23T19:10:35Z</dc:date>
    </item>
    <item>
      <title>Re: Awk Problem</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-problem/m-p/2770746#M942407</link>
      <description>By the way, you are aware that you could specify a -An od argument and suppress the offset column. That's the easy way to do this.&lt;BR /&gt;</description>
      <pubDate>Tue, 23 Jul 2002 19:26:03 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-problem/m-p/2770746#M942407</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2002-07-23T19:26:03Z</dc:date>
    </item>
    <item>
      <title>Re: Awk Problem</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-problem/m-p/2770747#M942408</link>
      <description>Hi Hai,JRF&lt;BR /&gt;&lt;BR /&gt;Thanks for your input, maybe I did not phrase it correctly.&lt;BR /&gt;What I need is, by looking at the sample file in hex, (as above) scan the file until 0100 26 (could be 01 0027 or 0100 28, it changes as goes on) for eg which is the first record and converting it to dec = 38 bytes long, so the output should look as follows&lt;BR /&gt;&lt;BR /&gt;0100 2601 1101 0200 1755 2400 003a 0000 0103 ff02 0102 0209 010a 0103 2191 3256 8f05 0601 0293 0471 1f,&lt;BR /&gt;which is equal to 38 bytes long counting from 0100 26. Please note that it's not always 38 bytes long, it could vary +- and again not taken the first coloumn into account.&lt;BR /&gt;&lt;BR /&gt;Once again &lt;BR /&gt;Thanks&lt;BR /&gt;Chris&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 23 Jul 2002 19:27:16 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-problem/m-p/2770747#M942408</guid>
      <dc:creator>Chris Frangandonis</dc:creator>
      <dc:date>2002-07-23T19:27:16Z</dc:date>
    </item>
    <item>
      <title>Re: Awk Problem</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-problem/m-p/2770748#M942409</link>
      <description>I'm not sure how-&lt;BR /&gt;&lt;BR /&gt;0100 2601 1101 0200 1755 2400 1755 2400 003a 0000 0103 ff02 0102 0209 010a 0103 2191 3256 8f05 0601 0293 0471 1f01 &lt;BR /&gt;01 0027 0111 0102 0017 5527 0001 7400 0002 03ff 0201 0202 0901 0f01 0321 9053 227f 0507 0102 0114 2442 95 &lt;BR /&gt;01 0027 0111 etc..... &lt;BR /&gt;&lt;BR /&gt;relates to your original file. Do you want 23 numbers grouped per line?&lt;BR /&gt;&lt;BR /&gt;Maybe more elaboration on how the resulting data should look would help.&lt;BR /&gt;&lt;BR /&gt;-- Rod Hills</description>
      <pubDate>Tue, 23 Jul 2002 19:28:49 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-problem/m-p/2770748#M942409</guid>
      <dc:creator>Rodney Hills</dc:creator>
      <dc:date>2002-07-23T19:28:49Z</dc:date>
    </item>
    <item>
      <title>Re: Awk Problem</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-problem/m-p/2770749#M942410</link>
      <description>Hi (again):&lt;BR /&gt;&lt;BR /&gt;You should look at 'xd' (also known as 'od').  As Clay noted, there are numerous options to 'xd'.  You can request the output in decimal, skip bytes, etc.  Note that 'xd' will read from standard-in so, of course, redirection from some other file or pipe will work!&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Tue, 23 Jul 2002 19:41:40 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-problem/m-p/2770749#M942410</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2002-07-23T19:41:40Z</dc:date>
    </item>
    <item>
      <title>Re: Awk Problem</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-problem/m-p/2770750#M942411</link>
      <description>Hi All,&lt;BR /&gt;&lt;BR /&gt;Many thanks for your input&lt;BR /&gt;I have attached a file which is colour format, maybe this would help.</description>
      <pubDate>Tue, 23 Jul 2002 19:42:08 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-problem/m-p/2770750#M942411</guid>
      <dc:creator>Chris Frangandonis</dc:creator>
      <dc:date>2002-07-23T19:42:08Z</dc:date>
    </item>
    <item>
      <title>Re: Awk Problem</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-problem/m-p/2770751#M942412</link>
      <description>If this is a binary file with a record "layout", then I would recommend creating a perl script to read the file directly. By writing a subroutine that would do the logical record reads, you could easily manipulate the file.&lt;BR /&gt;&lt;BR /&gt;-- Rod Hills&lt;BR /&gt;</description>
      <pubDate>Tue, 23 Jul 2002 19:43:41 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-problem/m-p/2770751#M942412</guid>
      <dc:creator>Rodney Hills</dc:creator>
      <dc:date>2002-07-23T19:43:41Z</dc:date>
    </item>
    <item>
      <title>Re: Awk Problem</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-problem/m-p/2770752#M942413</link>
      <description>Hi Rod,&lt;BR /&gt;&lt;BR /&gt;The answer to your question is "No", its in hex&lt;BR /&gt;&lt;BR /&gt;Thanks&lt;BR /&gt;Chris</description>
      <pubDate>Tue, 23 Jul 2002 19:51:58 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-problem/m-p/2770752#M942413</guid>
      <dc:creator>Chris Frangandonis</dc:creator>
      <dc:date>2002-07-23T19:51:58Z</dc:date>
    </item>
    <item>
      <title>Re: Awk Problem</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-problem/m-p/2770753#M942414</link>
      <description>In your attachment you indicated you were using "xd". Then you do have a binary file (xd displays data in a hex format).&lt;BR /&gt;&lt;BR /&gt;The following perl script could be used to read the orginal file (not the result of the xd).&lt;BR /&gt;&lt;BR /&gt;open(INP,"&lt;FILEINPUT&gt;&lt;/FILEINPUT&gt;seek INP,0x38,0;  # position past header&lt;BR /&gt;while(read(INP,$recsiz,3)) {   # get record size&lt;BR /&gt; ($b1,$rsiz)=unpack("c1,c2",$recsiz);&lt;BR /&gt; if (read(INP,$datum,$rsiz)) {&lt;BR /&gt;  $l=len($datum)-1;&lt;BR /&gt;  for $i (0..$l) {&lt;BR /&gt;   $c=substr($datum,$i,1);&lt;BR /&gt;   printf "%1.1x",$c;&lt;BR /&gt;   print " " if ($i % 2) != 0;&lt;BR /&gt;  }&lt;BR /&gt; }&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;-- Rod Hills&lt;BR /&gt;</description>
      <pubDate>Tue, 23 Jul 2002 20:18:22 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-problem/m-p/2770753#M942414</guid>
      <dc:creator>Rodney Hills</dc:creator>
      <dc:date>2002-07-23T20:18:22Z</dc:date>
    </item>
    <item>
      <title>Re: Awk Problem</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-problem/m-p/2770754#M942415</link>
      <description>oops, forgot to a line in the code. Insert&lt;BR /&gt;&lt;BR /&gt;print "\n";&lt;BR /&gt;&lt;BR /&gt;before the last 2 "}".&lt;BR /&gt;This way it will display a logical record in hex per text line of print.&lt;BR /&gt;&lt;BR /&gt;-- Rod Hills</description>
      <pubDate>Tue, 23 Jul 2002 20:26:25 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-problem/m-p/2770754#M942415</guid>
      <dc:creator>Rodney Hills</dc:creator>
      <dc:date>2002-07-23T20:26:25Z</dc:date>
    </item>
    <item>
      <title>Re: Awk Problem</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-problem/m-p/2770755#M942416</link>
      <description>Hi Ron, all&lt;BR /&gt;&lt;BR /&gt;Thanks for the input. I have run yor script but came back with errors "cant open file at .Open_perl line 3", so I changed the fileinput to its orig filename and still error "Undefined subroutine $main :: len called at .Open_perl line 9". I am at a learning stage of perl.&lt;BR /&gt;I know that awk can do the trick and have read a lot about it. Harry d Brown once helped me with a similar problem, but nowhere to be found. Still looking for an answer&lt;BR /&gt;&lt;BR /&gt;Many Thanks &lt;BR /&gt;Chris</description>
      <pubDate>Wed, 24 Jul 2002 16:03:10 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-problem/m-p/2770755#M942416</guid>
      <dc:creator>Chris Frangandonis</dc:creator>
      <dc:date>2002-07-24T16:03:10Z</dc:date>
    </item>
    <item>
      <title>Re: Awk Problem</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-problem/m-p/2770756#M942417</link>
      <description>Chris,&lt;BR /&gt;&lt;BR /&gt;Can you post your script, so that we can see the changes you made?&lt;BR /&gt;&lt;BR /&gt;thanks,&lt;BR /&gt;&lt;BR /&gt;live free or die&lt;BR /&gt;harry</description>
      <pubDate>Wed, 24 Jul 2002 16:16:27 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-problem/m-p/2770756#M942417</guid>
      <dc:creator>harry d brown jr</dc:creator>
      <dc:date>2002-07-24T16:16:27Z</dc:date>
    </item>
    <item>
      <title>Re: Awk Problem</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-problem/m-p/2770757#M942418</link>
      <description>'perl -v' is not showing 4.018 or something I hope?</description>
      <pubDate>Wed, 24 Jul 2002 16:18:36 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-problem/m-p/2770757#M942418</guid>
      <dc:creator>H.Merijn Brand (procura</dc:creator>
      <dc:date>2002-07-24T16:18:36Z</dc:date>
    </item>
    <item>
      <title>Re: Awk Problem</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-problem/m-p/2770758#M942419</link>
      <description>Hi Harry,&lt;BR /&gt;&lt;BR /&gt;Thanks once again. Once I can put the records in separate lines then the script will follow.&lt;BR /&gt;You once helped me with "reverse byte in hex" with conv to decimal.&lt;BR /&gt;&lt;BR /&gt;echo 1234 2345 3456 8e00 | awk ' &lt;BR /&gt;{ &lt;BR /&gt;hexstr="0123456789abcdef" &lt;BR /&gt;newnum=tolower(substr($4,3,2) substr($4,1,2)) &lt;BR /&gt;slen = length(newnum) &lt;BR /&gt;decnum = 0 &lt;BR /&gt;for (i=1; i &amp;lt; slen+1;i++) &lt;BR /&gt;{ &lt;BR /&gt;tpos = index(hexstr,substr(newnum,i,1)) - 1 &lt;BR /&gt;decnum = decnum + ( (16 ** (slen -i)) * tpos) &lt;BR /&gt;} &lt;BR /&gt;printf("%s is %d\n",newnum,decnum) &lt;BR /&gt;} ' &lt;BR /&gt;&lt;BR /&gt;Please look at my attachment.&lt;BR /&gt;&lt;BR /&gt;Many Thanks &lt;BR /&gt;Chris</description>
      <pubDate>Wed, 24 Jul 2002 16:35:39 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-problem/m-p/2770758#M942419</guid>
      <dc:creator>Chris Frangandonis</dc:creator>
      <dc:date>2002-07-24T16:35:39Z</dc:date>
    </item>
    <item>
      <title>Re: Awk Problem</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-problem/m-p/2770759#M942420</link>
      <description>I cannot look at a .doc attachment. Please use .txt, .sh (shar), .tgz (tar/gzip) or other readable unix formats.&lt;BR /&gt;&lt;BR /&gt;The script you show is awk, but you reported perl problems. A quick browse of that awk shows that whatever you are doing can be done much more simple in perl.</description>
      <pubDate>Thu, 25 Jul 2002 07:17:50 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-problem/m-p/2770759#M942420</guid>
      <dc:creator>H.Merijn Brand (procura</dc:creator>
      <dc:date>2002-07-25T07:17:50Z</dc:date>
    </item>
    <item>
      <title>Re: Awk Problem</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-problem/m-p/2770760#M942421</link>
      <description>With out the binary file, I can't fully test the script. But I fixed my original to correct syntax problems.&lt;BR /&gt;&lt;BR /&gt;Again use the perl script on the original binary file (not the "xd" output file). Replace "fileinput" with the name of the binary file.&lt;BR /&gt;&lt;BR /&gt;open(INP,"&lt;FILEINPUT&gt;&lt;/FILEINPUT&gt;seek INP,0x38,0;  # position past header&lt;BR /&gt;while(read(INP,$recsiz,3)) {   # get record size&lt;BR /&gt; ($b1,$rsiz)=unpack("c1,c2",$recsiz);&lt;BR /&gt; if (read(INP,$datum,$rsiz)) {&lt;BR /&gt;# uncomment next line if you want record size to be displayed too&lt;BR /&gt;# $datum=$recsiz . $datum;&lt;BR /&gt;  $l=length($datum)-1;&lt;BR /&gt;  for $i (0..$l) {&lt;BR /&gt;   $c=substr($datum,$i,1);&lt;BR /&gt;   printf "%1.1x",ord($c);&lt;BR /&gt;   print " " if ($i % 2) != 0;&lt;BR /&gt;  }&lt;BR /&gt;  print "\n";&lt;BR /&gt; }&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;Hope this works better.&lt;BR /&gt;&lt;BR /&gt;-- Rod Hills</description>
      <pubDate>Thu, 25 Jul 2002 13:27:04 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-problem/m-p/2770760#M942421</guid>
      <dc:creator>Rodney Hills</dc:creator>
      <dc:date>2002-07-25T13:27:04Z</dc:date>
    </item>
  </channel>
</rss>

