Operating System - Linux
1748019 Members
4423 Online
108757 Solutions
New Discussion юеВ

Re: how to count special characters?

 
SOLVED
Go to solution
H.Merijn Brand (procura
Honored Contributor

Re: how to count special characters?

*the* command to do so is 'freq' (if you have it). It's one of those lesser used pearls of the ol' unix times

a5:/u/usr/merijn 102 > freq .tcshrc
|nul 0| 1175|@ 6|` 34|
|soh 0|! 3|A 57|a 116|
|stx 0|" 104|B 8|b 75|
|etx 0|# 32|C 39|c 118|
|eot 0|$ 113|D 35|d 102|
|enq 0|% 42|E 99|e 415|
|ack 0|& 28|F 13|f 99|
|bel 2|' 66|G 8|g 25|
|bs 0|( 58|H 54|h 82|
|ht 192|) 60|I 37|i 207|
|lf 253|* 5|J 0|j 4|
|vt 0|+ 11|K 2|k 20|
|ff 0|, 27|L 45|l 138|
|cr 0|- 57|M 70|m 66|
|so 0|. 38|N 47|n 193|
|si 0|/ 199|O 80|o 137|
|dle 0|0 61|P 72|p 128|
|dc1 0|1 33|Q 3|q 3|
|dc2 0|2 21|R 76|r 171|
|dc3 0|3 19|S 77|s 312|
|dc4 0|4 6|T 93|t 278|
|nak 0|5 7|U 28|u 61|
|syn 0|6 12|V 8|v 79|
|etb 0|7 1|W 0|w 26|
|can 0|8 11|X 6|x 17|
|em 0|9 3|Y 14|y 37|
|sub 0|: 72|Z 1|z 1|
|esc 9|; 17|[ 9|{ 17|
|fs 0|< 4|\ 6|| 19|
|gs 0|= 163|] 8|} 17|
|rs 0|> 1|^ 14|~ 10|
|us 0|? 38|_ 25|del 0|
a5:/u/usr/merijn 103 >

freq also supports -a to show the 8-bit characters

Since many systems don't have it, I have included/attached the source code

Enjoy, Have FUN! H.Merijn
Enjoy, Have FUN! H.Merijn
Muthukumar_5
Honored Contributor

Re: how to count special characters?

You can try as,

echo 1,2,3,4,6 | perl -ne 's/[^,]//g;print length,"\n";'

hth.
Easy to suggest when don't know about the problem!
Arturo Galbiati
Esteemed Contributor

Re: how to count special characters?

Hi,
please, could you assign points?

0 point for this, of course

THX,
Art
Gemini_2
Regular Advisor

Re: how to count special characters?

After the first person replied me, I assigned the point right away and have not had visiting the forum for a while.

my apology. let me assign some points now.