SHARE
TWEET

Untitled

quantumech May 10th, 2019 78 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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]}"
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top