<?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: number of occurances of a character in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/number-of-occurances-of-a-character/m-p/4865400#M809043</link>
    <description>Thanks</description>
    <pubDate>Thu, 14 Oct 2004 14:48:20 GMT</pubDate>
    <dc:creator>Smaran</dc:creator>
    <dc:date>2004-10-14T14:48:20Z</dc:date>
    <item>
      <title>number of occurances of a character</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/number-of-occurances-of-a-character/m-p/4865388#M809031</link>
      <description>How do I count the number of occurances &lt;BR /&gt;of a particular character in an unix file?&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 14 Oct 2004 10:45:33 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/number-of-occurances-of-a-character/m-p/4865388#M809031</guid>
      <dc:creator>Smaran</dc:creator>
      <dc:date>2004-10-14T10:45:33Z</dc:date>
    </item>
    <item>
      <title>Re: number of occurances of a character</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/number-of-occurances-of-a-character/m-p/4865389#M809032</link>
      <description>cat filename | wc -m&lt;BR /&gt;&lt;BR /&gt;That will give you a count&lt;BR /&gt;&lt;BR /&gt;count=$(cat filename | wc -m)&lt;BR /&gt;&lt;BR /&gt;echo $count&lt;BR /&gt;&lt;BR /&gt;SEP</description>
      <pubDate>Thu, 14 Oct 2004 10:52:04 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/number-of-occurances-of-a-character/m-p/4865389#M809032</guid>
      <dc:creator>Steven E. Protter</dc:creator>
      <dc:date>2004-10-14T10:52:04Z</dc:date>
    </item>
    <item>
      <title>Re: number of occurances of a character</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/number-of-occurances-of-a-character/m-p/4865390#M809033</link>
      <description>If you don't want to do it interactively, you could open the file in vi, and eg to count the "a"'s: -&lt;BR /&gt;&lt;BR /&gt;:%s/a/A/g&lt;BR /&gt;&lt;BR /&gt;It will tell you "437 substitutions".  Then don't save the file.&lt;BR /&gt;&lt;BR /&gt;I had hoped that "ed" would report a similar output so you could do: -&lt;BR /&gt;&lt;BR /&gt;ed file &amp;lt;&lt;EOF&gt;&lt;/EOF&gt;1,$s/a/A/g&lt;BR /&gt;q&lt;BR /&gt;EOF&lt;BR /&gt;&lt;BR /&gt;and read the output, but it seems not to.  This should get you started though.</description>
      <pubDate>Thu, 14 Oct 2004 10:52:55 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/number-of-occurances-of-a-character/m-p/4865390#M809033</guid>
      <dc:creator>Simon Hargrave</dc:creator>
      <dc:date>2004-10-14T10:52:55Z</dc:date>
    </item>
    <item>
      <title>Re: number of occurances of a character</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/number-of-occurances-of-a-character/m-p/4865391#M809034</link>
      <description># man freq&lt;BR /&gt;&lt;BR /&gt;# freq file&lt;BR /&gt;&lt;BR /&gt;And in perl (not tested)&lt;BR /&gt;# perl -ne'$c{$_}++ for split//;END{for(sort keys%c{printf"%3d %2s %6d\n",ord$_,$_ lt" "?"^".($_|"@"):$_,$c{$_}}}' file&lt;BR /&gt;&lt;BR /&gt;Enjoy, Have FUN! H.Merijn</description>
      <pubDate>Thu, 14 Oct 2004 10:55:03 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/number-of-occurances-of-a-character/m-p/4865391#M809034</guid>
      <dc:creator>H.Merijn Brand (procura</dc:creator>
      <dc:date>2004-10-14T10:55:03Z</dc:date>
    </item>
    <item>
      <title>Re: number of occurances of a character</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/number-of-occurances-of-a-character/m-p/4865392#M809035</link>
      <description>Ahh, ohh, I counted the number of occurences of every single character in the file :/&lt;BR /&gt;&lt;BR /&gt;a5:/u/usr/merijn 109 &amp;gt; freq .Xdefaults | grep -w a&lt;BR /&gt;|soh       0|!        91|A         8|a       335|&lt;BR /&gt;a5:/u/usr/merijn 110 &amp;gt; perl -nle'END{print$a}$a+=(tr/a/a/)' .Xdefaults&lt;BR /&gt;335&lt;BR /&gt;a5:/u/usr/merijn 111 &amp;gt;&lt;BR /&gt;&lt;BR /&gt;Enjoy, Have Fun</description>
      <pubDate>Thu, 14 Oct 2004 10:58:46 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/number-of-occurances-of-a-character/m-p/4865392#M809035</guid>
      <dc:creator>H.Merijn Brand (procura</dc:creator>
      <dc:date>2004-10-14T10:58:46Z</dc:date>
    </item>
    <item>
      <title>Re: number of occurances of a character</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/number-of-occurances-of-a-character/m-p/4865393#M809036</link>
      <description>Here is how it can be done with "awk".&lt;BR /&gt; &lt;BR /&gt;echo "abcadefgabf\nkhaeeaf" | awk -Fa '{s=s+NF-1};END{print s}'&lt;BR /&gt; &lt;BR /&gt;This will count number of "a" in file.&lt;BR /&gt; &lt;BR /&gt;Here is how it can be done with "perl".&lt;BR /&gt; &lt;BR /&gt;echo "abcadefgabf\nkhaeeaf" | perl -ne '$n=s/a//g;$s+=$n;END{print $s,"\n";}'&lt;BR /&gt; &lt;BR /&gt;HTH&lt;BR /&gt; &lt;BR /&gt;-- Rod Hills</description>
      <pubDate>Thu, 14 Oct 2004 11:02:27 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/number-of-occurances-of-a-character/m-p/4865393#M809036</guid>
      <dc:creator>Rodney Hills</dc:creator>
      <dc:date>2004-10-14T11:02:27Z</dc:date>
    </item>
    <item>
      <title>Re: number of occurances of a character</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/number-of-occurances-of-a-character/m-p/4865394#M809037</link>
      <description>perl use is throwing the following errors&lt;BR /&gt;syntax error in file /tmp/perl-ea02209 at line 1, next 2 tokens "END {"&lt;BR /&gt;syntax error in file /tmp/perl-ea02209 at line 2, next token "}"       &lt;BR /&gt;Execution of /tmp/perl-ea02209 aborted due to compilation errors.      &lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 14 Oct 2004 11:06:59 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/number-of-occurances-of-a-character/m-p/4865394#M809037</guid>
      <dc:creator>Smaran</dc:creator>
      <dc:date>2004-10-14T11:06:59Z</dc:date>
    </item>
    <item>
      <title>Re: number of occurances of a character</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/number-of-occurances-of-a-character/m-p/4865395#M809038</link>
      <description>Sounds like you have /usr/contrib/bin in your $PATH before (if any) a more modern perl5:&lt;BR /&gt;&lt;BR /&gt;a5:/u/usr/merijn 112 &amp;gt; /usr/contrib/bin/perl -nle'END{print$a}$a+=(tr/a/a/)' .Xdefaults&lt;BR /&gt;syntax error in file /tmp/perl-ea03721 at line 1, next token "."&lt;BR /&gt;Execution of /tmp/perl-ea03721 aborted due to compilation errors.&lt;BR /&gt;Exit 2&lt;BR /&gt;a5:/u/usr/merijn 113 &amp;gt;&lt;BR /&gt;&lt;BR /&gt;That's from perl4&lt;BR /&gt;&lt;BR /&gt;perl4 should be happy with this:&lt;BR /&gt;&lt;BR /&gt;a5:/u/usr/merijn 124 &amp;gt; /usr/contrib/bin/perl -le 'while(&amp;lt;&amp;gt;){$a+=y/a/a/}print$a' .Xdefaults&lt;BR /&gt;335&lt;BR /&gt;a5:/u/usr/merijn 125 &amp;gt;&lt;BR /&gt;&lt;BR /&gt;Enjoy, Have FUN! H.Merijn</description>
      <pubDate>Thu, 14 Oct 2004 11:21:31 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/number-of-occurances-of-a-character/m-p/4865395#M809038</guid>
      <dc:creator>H.Merijn Brand (procura</dc:creator>
      <dc:date>2004-10-14T11:21:31Z</dc:date>
    </item>
    <item>
      <title>Re: number of occurances of a character</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/number-of-occurances-of-a-character/m-p/4865396#M809039</link>
      <description>For procura,&lt;BR /&gt;&lt;BR /&gt;I do not have freq command. I am on 11i.&lt;BR /&gt;where is that command.&lt;BR /&gt;&lt;BR /&gt;Anil</description>
      <pubDate>Thu, 14 Oct 2004 11:26:56 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/number-of-occurances-of-a-character/m-p/4865396#M809039</guid>
      <dc:creator>RAC_1</dc:creator>
      <dc:date>2004-10-14T11:26:56Z</dc:date>
    </item>
    <item>
      <title>Re: number of occurances of a character</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/number-of-occurances-of-a-character/m-p/4865397#M809040</link>
      <description>echo $(( $(sed "s/[^a]//g" /etc/passwd|wc -m) - $(cat /etc/passwd|wc -l) ))&lt;BR /&gt;&lt;BR /&gt;-&amp;gt; Count a on each line - number of lines&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;&lt;BR /&gt;Fred&lt;BR /&gt;</description>
      <pubDate>Thu, 14 Oct 2004 12:18:04 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/number-of-occurances-of-a-character/m-p/4865397#M809040</guid>
      <dc:creator>Fred Ruffet</dc:creator>
      <dc:date>2004-10-14T12:18:04Z</dc:date>
    </item>
    <item>
      <title>Re: number of occurances of a character</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/number-of-occurances-of-a-character/m-p/4865398#M809041</link>
      <description>Comes from System III times.&lt;BR /&gt;Old but VERY useful (when you need it)&lt;BR /&gt;&lt;BR /&gt;Source attached&lt;BR /&gt;&lt;BR /&gt;I'm so used to having it that I forgot It was from source.&lt;BR /&gt;&lt;BR /&gt;On some systems (like Linux) you'll need an additional &lt;BR /&gt;&lt;BR /&gt;#include &lt;ERRNO.H&gt;&lt;BR /&gt;&lt;BR /&gt;Enjoy, Have FUNE H.Merijn&lt;/ERRNO.H&gt;</description>
      <pubDate>Thu, 14 Oct 2004 12:50:14 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/number-of-occurances-of-a-character/m-p/4865398#M809041</guid>
      <dc:creator>H.Merijn Brand (procura</dc:creator>
      <dc:date>2004-10-14T12:50:14Z</dc:date>
    </item>
    <item>
      <title>Re: number of occurances of a character</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/number-of-occurances-of-a-character/m-p/4865399#M809042</link>
      <description>Hi,&lt;BR /&gt;you can do it with a little workaround - at least I think so. Example of an input file:&lt;BR /&gt; &lt;BR /&gt;# cat infile&lt;BR /&gt;abc&lt;BR /&gt;defg&lt;BR /&gt;hij&lt;BR /&gt;kl&lt;BR /&gt;amn&lt;BR /&gt;opq&lt;BR /&gt;raa&lt;BR /&gt;sta&lt;BR /&gt; &lt;BR /&gt;Count all chars of infile:&lt;BR /&gt;# wc -c infile&lt;BR /&gt;32 infile&lt;BR /&gt; &lt;BR /&gt;Now fake a deletion of the char in question, e.g. "a", and count the remaining:&lt;BR /&gt;# tr -d a  &lt;INFILE&gt;&lt;/INFILE&gt;27&lt;BR /&gt;&lt;BR /&gt;Just a suggestion...&lt;BR /&gt;&lt;BR /&gt;John K.</description>
      <pubDate>Thu, 14 Oct 2004 14:46:21 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/number-of-occurances-of-a-character/m-p/4865399#M809042</guid>
      <dc:creator>john korterman</dc:creator>
      <dc:date>2004-10-14T14:46:21Z</dc:date>
    </item>
    <item>
      <title>Re: number of occurances of a character</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/number-of-occurances-of-a-character/m-p/4865400#M809043</link>
      <description>Thanks</description>
      <pubDate>Thu, 14 Oct 2004 14:48:20 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/number-of-occurances-of-a-character/m-p/4865400#M809043</guid>
      <dc:creator>Smaran</dc:creator>
      <dc:date>2004-10-14T14:48:20Z</dc:date>
    </item>
    <item>
      <title>Re: number of occurances of a character</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/number-of-occurances-of-a-character/m-p/4865401#M809044</link>
      <description>Mr. Hills, the awk method for finding "a" was very useful for me -- it is appreciated.&lt;BR /&gt;&lt;BR /&gt;I modified the awk to find the number of occurrences of "/".  I find that the perl does not seem to be able to handle this as written (is further modification required?)Here are the versions of your code with "/" substituted for "a" (see post from Rodney Hills above for original code):&lt;BR /&gt;&lt;BR /&gt;Works:&lt;BR /&gt;#echo "/m03/oracle/oradata" | awk -F/ '{s=s+NF-1};END{print s}'&lt;BR /&gt;3&lt;BR /&gt;&lt;BR /&gt;Does Not Work:&lt;BR /&gt;#echo "abcadefgabf\nkhaeeaf" | perl -ne '$n=s/\//g;$s+=$n;END{print $s,"\n";}'&lt;BR /&gt;Substitution replacement not terminated at -e line 1.&lt;BR /&gt;&lt;BR /&gt;Also Does not Work (gives "incorrect" result):&lt;BR /&gt;#echo "abcadefgabf\nkhaeeaf" | perl -ne '$n=s/\\//g;$s+=$n;END{print $s,"\n";}'&lt;BR /&gt;0&lt;BR /&gt;&lt;BR /&gt;Is additional code required in the perl example to handle special characters like "$", ".", "/" etc. ?&lt;BR /&gt;Gil&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Wed, 05 Oct 2005 12:05:11 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/number-of-occurances-of-a-character/m-p/4865401#M809044</guid>
      <dc:creator>Gilbert Standen_1</dc:creator>
      <dc:date>2005-10-05T12:05:11Z</dc:date>
    </item>
  </channel>
</rss>

