Skip to content

Instantly share code, notes, and snippets.

@bobbykjack
Created April 10, 2022 11:52
Show Gist options
  • Save bobbykjack/5f470020c2714fca0a8563ecbe4e3e43 to your computer and use it in GitHub Desktop.
Save bobbykjack/5f470020c2714fca0a8563ecbe4e3e43 to your computer and use it in GitHub Desktop.
Examples of basic bash array syntax
#!/bin/bash
city=(London Paris Milan "New York")
echo ${city[3]}
# New York
echo ${#city[@]}
# 4
city+=(Rome)
echo ${city[@]}
# London Paris Milan New York Rome
echo ${city[@]:2:2}
# Milan New York
echo ${city[@]:3}
# New York Rome
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment