fork download
  1. #!/bin/bash
  2.  
  3. # process standard input
  4. while read -a line; do
  5. for word in ${line[@]}; do
  6. len=${#word}
  7. lengths[len]=$((${lengths[len]}+1))
  8.  
  9. for((j=0; j<${#word};++j)); do
  10. letters+=${word:j:1}
  11. done
  12. done
  13. done
  14.  
  15. echo "character statistics:"
  16. echo $letters | fold -w 1 | sort | uniq -c | sort -rn
  17.  
  18. echo "word length statistics:"
  19. for i in ${!lengths[*]}; do
  20. echo "Found ${lengths[i]} words of length $i"
  21. done
  22.  
Success #stdin #stdout 0.03s 5268KB
stdin
a	c	e	n	o	p
a	c	e		o	p
a	c	e		o	
	c	e
	c	e
		e

sat       so       dive
sit       do       seek
dig                pole
pig                love
log
boo
stdout
character statistics:
     11 e
      8 o
      5 c
      4 s
      4 p
      4 i
      4 a
      3 l
      3 g
      3 d
      2 v
      2 t
      1 n
      1 k
word length statistics:
Found 20 words of length 1
Found 2 words of length 2
Found 5 words of length 3
Found 4 words of length 4