Advertisement
Sergio_Istea

2dimensionarrays.sh

Oct 26th, 2022
1,216
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.63 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3.  
  4. #declare -A arr
  5.  
  6. # Formato array 2 dimensiones
  7.  
  8.  
  9. # asginar un elemento a una posicion
  10. # arr[indiceFila,indiceColumna]=valor
  11.  
  12. echo "Array de dos dimensiones
  13. "
  14.  
  15. echo "  0 1"
  16. echo "0 a b"
  17. echo "1 c d"
  18.  
  19. echo "
  20. declare -A alpha=([0,0]=a [0,1]=b [1,0]=c [1,1]=d)"
  21. declare -A alpha=([0,0]=a [0,1]=b [1,0]=c [1,1]=d)
  22.  
  23. echo "echo \${alpha[0,1]}
  24. "
  25. echo ${alpha[0,1]}
  26. echo "
  27. echo \${alpha[1,0]}"
  28. echo ${alpha[1,0]}
  29. echo "
  30. echo \${alpha[1,1]}"
  31. echo ${alpha[1,1]}
  32.  
  33.  
  34.  
  35. echo "
  36. echo \${alpha[@]}"
  37. echo "${alpha[@]}"
  38.  
  39. echo "alpha[1,1]=D"
  40. alpha[1,1]=D
  41.  
  42. echo "
  43. echo \${alpha[1,1]}"
  44. echo ${alpha[1,1]}
  45.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement