Skip to content

Instantly share code, notes, and snippets.

@changx03
Created July 14, 2022 02:24
Show Gist options
  • Save changx03/9c001f3b3f8a31cdcca44f5bb6b88fc2 to your computer and use it in GitHub Desktop.
Save changx03/9c001f3b3f8a31cdcca44f5bb6b88fc2 to your computer and use it in GitHub Desktop.
Access an element from an array using index in bash
#!/bin/bash
# To access banana
DATA=("apple" "banana" "cherry")
IDX=1
echo ${DATA[$IDX]}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment