Advertisement
quantumech

Untitled

May 10th, 2019
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.52 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. # Declaring arrays in Bash is similar to declaring tuples in Python
  4. array=('1' '2' 2 5)
  5.  
  6. # You can set any index of an array to be a value in Bash, What this does is allocate 1000 - 4 values and sets the last index to 100
  7. array[1000]=100
  8.  
  9. # Delete the 1000th index
  10. unset array[1000]
  11.  
  12. # Print values of all elements in array
  13. echo "${array[@]}"
  14.  
  15. # Print indexes of all elements in array
  16. echo "${!array[@]}"
  17.  
  18. # Print length of array
  19. echo "${#array[@]}"
  20.  
  21. # Print 0th element of array
  22. echo "${array[0]}"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement