<?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: character counting an manipulation in Operating System - Linux</title>
    <link>https://community.hpe.com/t5/operating-system-linux/character-counting-an-manipulation/m-p/5070706#M94901</link>
    <description>&lt;!--!*#--&gt;The following echos the truncated lines along with the lines &amp;lt;= 48 bytes.&lt;BR /&gt;Lines over 48 bytes are sent to bad_row:&lt;BR /&gt;&amp;gt; bad_row # empty file&lt;BR /&gt;awk '&lt;BR /&gt;{&lt;BR /&gt;len = length($0)&lt;BR /&gt;if (len &amp;gt; 48) {&lt;BR /&gt;   print $0 &amp;gt;&amp;gt; "bad_row"&lt;BR /&gt;   $0 = substr($0, 1, 48)  # chop to 48&lt;BR /&gt;}&lt;BR /&gt;print $0&lt;BR /&gt;} ' &lt;FILE&gt;&lt;/FILE&gt;</description>
    <pubDate>Tue, 25 Sep 2007 04:08:05 GMT</pubDate>
    <dc:creator>Dennis Handly</dc:creator>
    <dc:date>2007-09-25T04:08:05Z</dc:date>
    <item>
      <title>character counting an manipulation</title>
      <link>https://community.hpe.com/t5/operating-system-linux/character-counting-an-manipulation/m-p/5070705#M94900</link>
      <description>hello all,]&lt;BR /&gt;&lt;BR /&gt;I am working on a task to:&lt;BR /&gt;&lt;BR /&gt;count each character in each row then if the row is over 48 characters log that row to a new file and delete all characters after 48:&lt;BR /&gt;&lt;BR /&gt;so I want to use awk to initally deterrmine what rows are over 48 characters but cannot get the syntax:&lt;BR /&gt;&lt;BR /&gt;awk '{nc = nc + lenght($0) +1 } {if( nc &amp;gt; 48 ) print nc}' &lt;FILE&gt;&lt;BR /&gt;&lt;BR /&gt;any help please?&lt;BR /&gt;&lt;BR /&gt;chris.&lt;/FILE&gt;</description>
      <pubDate>Tue, 25 Sep 2007 03:45:12 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/character-counting-an-manipulation/m-p/5070705#M94900</guid>
      <dc:creator>lawrenzo_1</dc:creator>
      <dc:date>2007-09-25T03:45:12Z</dc:date>
    </item>
    <item>
      <title>Re: character counting an manipulation</title>
      <link>https://community.hpe.com/t5/operating-system-linux/character-counting-an-manipulation/m-p/5070706#M94901</link>
      <description>&lt;!--!*#--&gt;The following echos the truncated lines along with the lines &amp;lt;= 48 bytes.&lt;BR /&gt;Lines over 48 bytes are sent to bad_row:&lt;BR /&gt;&amp;gt; bad_row # empty file&lt;BR /&gt;awk '&lt;BR /&gt;{&lt;BR /&gt;len = length($0)&lt;BR /&gt;if (len &amp;gt; 48) {&lt;BR /&gt;   print $0 &amp;gt;&amp;gt; "bad_row"&lt;BR /&gt;   $0 = substr($0, 1, 48)  # chop to 48&lt;BR /&gt;}&lt;BR /&gt;print $0&lt;BR /&gt;} ' &lt;FILE&gt;&lt;/FILE&gt;</description>
      <pubDate>Tue, 25 Sep 2007 04:08:05 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/character-counting-an-manipulation/m-p/5070706#M94901</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2007-09-25T04:08:05Z</dc:date>
    </item>
    <item>
      <title>Re: character counting an manipulation</title>
      <link>https://community.hpe.com/t5/operating-system-linux/character-counting-an-manipulation/m-p/5070707#M94902</link>
      <description>i have also attempted to get the sum of the number of characters in each filed with no avail:&lt;BR /&gt;&lt;BR /&gt;awk '{ sum = 0; for (i = 1; i &amp;lt;= NF; i = i +1) sum = sum + $i; print sum}' &lt;FILE&gt;&lt;BR /&gt;&lt;BR /&gt;Thanks&lt;/FILE&gt;</description>
      <pubDate>Tue, 25 Sep 2007 04:08:14 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/character-counting-an-manipulation/m-p/5070707#M94902</guid>
      <dc:creator>lawrenzo_1</dc:creator>
      <dc:date>2007-09-25T04:08:14Z</dc:date>
    </item>
    <item>
      <title>Re: character counting an manipulation</title>
      <link>https://community.hpe.com/t5/operating-system-linux/character-counting-an-manipulation/m-p/5070708#M94903</link>
      <description>Thanks Dennis,&lt;BR /&gt;&lt;BR /&gt;I should have mentioned that this statement is being run on system V unix (doh)&lt;BR /&gt;&lt;BR /&gt;I run the script on system V as it is and get:&lt;BR /&gt;&lt;BR /&gt;16004409190000000100000000000019058051-001&lt;BR /&gt;160044092100619510300000000000190580014144&lt;BR /&gt;160044092305516610300000000000190580014145&lt;BR /&gt;160044092561568811100000000000190580014146&lt;BR /&gt;160044092782197010000000000000190580014147&lt;BR /&gt;160044092901235110000000000000190580014148&lt;BR /&gt;160044093103418510000000000000190580014149&lt;BR /&gt;16004409334364  10300000000000190580014150&lt;BR /&gt;160044093529527910500000000000190580014151&lt;BR /&gt;16004409372859  10200000000000190580014152&lt;BR /&gt;16004409394836  10800000000000190580014153&lt;BR /&gt;160044094101939810000000000000190580014154&lt;BR /&gt;160044094392    10000000000000190580014155&lt;BR /&gt;160044094501982810000000000000190580014156&lt;BR /&gt;16004409474463  10200000000000190580014157&lt;BR /&gt;awk: can't set $0&lt;BR /&gt; record number 16&lt;BR /&gt;&lt;BR /&gt;so the code works and bad_row file has the bad data however for some reason when:&lt;BR /&gt;&lt;BR /&gt;$0 = substr($0, 1, 42)&lt;BR /&gt;&lt;BR /&gt;the code fails - is anyone aware of the correct syntax for this?&lt;BR /&gt;&lt;BR /&gt;Chris.</description>
      <pubDate>Tue, 25 Sep 2007 05:19:47 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/character-counting-an-manipulation/m-p/5070708#M94903</guid>
      <dc:creator>lawrenzo_1</dc:creator>
      <dc:date>2007-09-25T05:19:47Z</dc:date>
    </item>
    <item>
      <title>Re: character counting an manipulation</title>
      <link>https://community.hpe.com/t5/operating-system-linux/character-counting-an-manipulation/m-p/5070709#M94904</link>
      <description>Hi Chris:&lt;BR /&gt;&lt;BR /&gt;&amp;gt; I  have also attempted to get the sum of the number of characters in each filed with no avail:&lt;BR /&gt;&lt;BR /&gt;Use 'length'.  For example:&lt;BR /&gt;&lt;BR /&gt;# echo "here is one"|awk '{for (i=1;i&amp;lt;=NF;i++) {print length($i)}}'&lt;BR /&gt;&lt;BR /&gt;4&lt;BR /&gt;2&lt;BR /&gt;3&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Tue, 25 Sep 2007 05:27:45 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/character-counting-an-manipulation/m-p/5070709#M94904</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2007-09-25T05:27:45Z</dc:date>
    </item>
    <item>
      <title>Re: character counting an manipulation</title>
      <link>https://community.hpe.com/t5/operating-system-linux/character-counting-an-manipulation/m-p/5070710#M94905</link>
      <description>&lt;!--!*#--&gt;$0 = substr($0, 1, 42)&lt;BR /&gt;&amp;gt;the code fails - is anyone aware of the correct syntax for this?&lt;BR /&gt;&lt;BR /&gt;I assume if you have a lemon awk, you can use nawk?&lt;BR /&gt;&lt;BR /&gt;Otherwise use another variable:&lt;BR /&gt;record = $0&lt;BR /&gt;if (len &amp;gt; 48) {&lt;BR /&gt;   print $0 &amp;gt;&amp;gt; "bad_row"&lt;BR /&gt;   record = substr($0, 1, 48)  # chop to 48&lt;BR /&gt;}&lt;BR /&gt;print record</description>
      <pubDate>Tue, 25 Sep 2007 05:35:15 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/character-counting-an-manipulation/m-p/5070710#M94905</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2007-09-25T05:35:15Z</dc:date>
    </item>
    <item>
      <title>Re: character counting an manipulation</title>
      <link>https://community.hpe.com/t5/operating-system-linux/character-counting-an-manipulation/m-p/5070711#M94906</link>
      <description>thanks guys again for the expamples.&lt;BR /&gt;&lt;BR /&gt;Dennis you were correct and nawk worked a treat.&lt;BR /&gt;&lt;BR /&gt;And james&lt;BR /&gt;&lt;BR /&gt;Thanks for your input - this has helped me solve the next part of my script.&lt;BR /&gt;&lt;BR /&gt;:-)&lt;BR /&gt;&lt;BR /&gt;Chris</description>
      <pubDate>Tue, 25 Sep 2007 06:23:00 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/character-counting-an-manipulation/m-p/5070711#M94906</guid>
      <dc:creator>lawrenzo_1</dc:creator>
      <dc:date>2007-09-25T06:23:00Z</dc:date>
    </item>
  </channel>
</rss>

