#!/bin/bashDIALOG=${DIALOG=dialog}declare -a lines declare -a simboliaideclare -a skaiciusdeclare -a skirtukai declare -a skirtuku E_BADARGS=65let i=0 let a=0 skirtukai=”, “
#+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++print (){ le=${#simboliai[*]} sk=0 echo ” File: ‘$FILE’ stats” echo ” ~~~~~~~~~~~~~~~~~~~~~~~~~~” echo echo echo echo “———————–” echo “|SIMBOLIS | DAZNUMAS” echo “———————–” filename=$OUTFILE echo “File: ‘$FILE’ stats” > $filename while [ $sk -lt $le ] do echo “|${simboliai[sk]} | ${skaicius[sk]}” >> $filename echo “|${simboliai[sk]} | ${skaicius[sk]}” let sk=sk+1 done echo “———————–” }#+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++clear (){let index=0 while [ $index -lt 50 ] do echo let index=index+1 done}#+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++split (){ nz=0 splitLength=${#skirtukai} echo “SKIRTUKAI: $skirtukai” echo “Skirtuku skaicius: $splitLength” while [ $nz -lt $splitLength ] do skirtuku[nz]=${skirtukai:$nz:1} echo “$nz ————- ${skirtuku[nz]}” let nz=nz+1 done skirtuku[nz]=””}#+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++Help (){$DIALOG –title “HELP” –clear –yesno ” Pasirinkite viena is meniu punktu n Iveskite ivedimo failo pavadinima n Iveskite isvedimo failo pavadinima n Created by Nerijus Kliauba n Lotynisku raidziu statistika nnn Continue?” 20 60 case $? in 0) ;; 1) exit $?;; esac}#+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++Count (){ split; exec 3< “$FILE” while read curline <&3; do if [ -z “$curline” -o “${curline:0:1}” = “#” ]; then continue; fi lines=(“${lines[@]}” “$curline”)lineLength=${#lines[i]}line=${lines[i]}x=0le=0
while [ $x -lt $lineLength ]do ind=0 hi=${#skirtuku[*]} le=${#simboliai[*]} sk=0 tikrinti=0 pass=0 masyvas[x]=${line:$x:1}#——————————————— while [ $ind -lt $hi ] do if [[ ${masyvas[x]} == ${skirtuku[ind]} ]]; then echo ” RASTAS SKIRTUKAS:” echo “$ind – |${skirtuku[ind]}|” pass=1 fi let ind=ind+1 done#———————————————-if [ $pass == 0 ];then echo “KAS eina: ${masyvas[x]}” #———————————————- if [ $le == 0 ]; then simboliai[le]=${masyvas[x]} skaicius[le]=1 fi#———————————————- while [ $sk -lt $le ] do if [[ ${simboliai[sk]} == ${masyvas[x]} ]]; then temp2=${skaicius[sk]} let temp2=temp2+1 skaicius[sk]=$temp2 tikrinti=1 fi let sk=sk+1 done#——————————————— if [ $tikrinti == 0 ]; then simboliai[le]=${masyvas[x]} skaicius[le]=1 fi#———————————————- fi#———————————————— let x=x+1 done let i=i+1done exec 3<&-}#+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++# 29 Checks if file exists.chfl (){ if [ ! -f $FILE ]; then
echo “File “$FILE” doesn’t exist.” Help echo “Write filename:” read FILE fi}#8888888888888888888888888888888888888888888888888888888888888888888#88888888888888888888888 MAIN’as 8888888888888888888888888888888#8888888888888888888888888888888888888888888888888888888888888888888clear;echo “——————————————-“echo “| MENIU |”echo “——————————————-“echo ” created By Nerijus Kliauba”echo “”echo “”echo ” 1. Run”echo ” 2. Help”echo ” 3. Exit”echo “”echo “”echo “Pasirinkite:”read komandacase “$komanda” in 1) clear; echo “Write input filename:” read FILE clear; echo “Write output filename:” read OUTFILE clear chfl; clear; Count; print; ;; 2) Help; clear; echo “Write input filename:” read FILE clear; echo “Write output filename:” read OUTFILE clear chfl; clear; Count; print; ;; 3) exit 0 ;; *) Help; exit 0 ;;esacexit $?