Advertisement
Guest User

Backup1

a guest
Jan 24th, 2020
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.74 KB | None | 0 0
  1. #Go to bin directory
  2. cd /bin
  3. #Print out bin files
  4. #ls /bin
  5.  
  6. #Storing bin files names on var
  7. # files="$(ls /bin)"
  8.  
  9. #Char parameter
  10. parameter=$1
  11. char=${parameter:0:1}
  12.  
  13. #Consonants
  14. consonants=( b, c, d, f, g, h, j, k, l, m, n, p, q, r, s, t, v, w, x, y, z)
  15.  
  16. #Storing bin files names into an array
  17. array=( $(ls .) )
  18.  
  19. # echo "${array[10]}"
  20.  
  21. # echo $char
  22.  
  23. if [ $char ]
  24. then
  25.     for file in ${array[@]}
  26.     do        
  27.         #If filename string is greather than 3
  28.         if [ ${#file} -gt 3 ]
  29.         then
  30.             #If third char is equal to char var
  31.             if [ ${file:2:1} = $char ]
  32.             then
  33.                 echo $file
  34.             fi          
  35.         fi
  36.     done
  37. else
  38.     echo "No ha enviado un parametro"
  39. fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement