Advertisement
Guest User

Count.sh 7:11 17

a guest
Sep 17th, 2016
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.10 KB | None | 0 0
  1. # Use this to open in emacs, I assume.
  2. #!/bin/bash
  3.  
  4. echo "Hello World!"
  5. echo Hello World! #Seems to work fine even without double quotes
  6.  
  7. numberofcharacters=0
  8. index=0
  9. count=0
  10. char=0
  11.  
  12. x[0]=0
  13. y[0]=0
  14.  
  15. for file in /bin/* #/bin/whatevercommand
  16. do
  17.     {
  18.     echo $file
  19.    
  20.     string=$file #NO SPACES, OR ELSE IT IS INTERPRETED AS A COMMAND
  21.    
  22.     echo $string  #should print duplicates
  23.    
  24.         echo ${string:5:1}
  25.    
  26.     character=${string:5:1}
  27.    
  28.     if [[ $character == [a-z] ]] #Can only use == becuase of double "test"
  29.         then
  30.         {
  31.         echo "Its a character" $character  #If it was just [] need to use -eq
  32.         echo "Char is " $char
  33.                
  34.         if [[ $char==$character ]]
  35.         then
  36.             {   echo "Accessed 1 "
  37.             current=${y[index]}
  38.                (( y[index]=$current+1))
  39.  
  40.  
  41.             }
  42.         else
  43.             {
  44.             echo "Accessed 2"
  45.             char=$character
  46.            
  47.             ((index++))
  48.             y[index]=1 #It equals 1 because we just saw the new character
  49.             x[index]=$character
  50.             }
  51.  
  52.             fi                      
  53.  
  54.         }
  55.     fi
  56.     }
  57.            done
  58.  
  59.  
  60.  
  61.  
  62. #echo "Y @ " ${y[@]}
  63. echo "X @ " ${x[@]}
  64.  
  65. echo "Char " $char
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement