Created
April 10, 2022 11:52
-
-
Save bobbykjack/5f470020c2714fca0a8563ecbe4e3e43 to your computer and use it in GitHub Desktop.
Examples of basic bash array syntax
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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