Advertisement
Guest User

Untitled

a guest
Apr 27th, 2024
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. #!/usr/bin/env bash
  2.  
  3.  
  4.  
  5. check_scrabble()
  6. {
  7.  
  8. local score=0
  9.  
  10. local json_data='{
  11. "1": ["A", "E", "I", "O", "U", "L", "N", "R", "S", "T"],
  12. "2": ["D", "G"],
  13. "3": ["B", "C", "M", "P"],
  14. "4": ["F", "H", "V", "W", "Y"],
  15. "5": ["K"],
  16. "8": ["J", "X"],
  17. "10": ["Q", "Z"]
  18. }'
  19.  
  20.  
  21. item="DOG"
  22. for ((j=0; j<${#item}; j++)); do
  23. echo "Element at index $j: ${item:$j:1}"
  24. for entry in $(echo "$json_data" | jq '.[] | select(.[] | contains("${item:$j:1}"))'); do
  25. echo "inside for loop $entry"
  26. done
  27. done
  28.  
  29.  
  30. }
  31.  
  32.  
  33. main () {
  34.  
  35. check_scrabble "$@"
  36.  
  37. }
  38.  
  39.  
  40. main "$@"
  41.  
  42.  
  43.  
Tags: BASH
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement