Created
March 19, 2020 12:24
-
-
Save aleofreddi/e26609dde53c2d0198130bccfcc073b3 to your computer and use it in GitHub Desktop.
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
# Bash array cheatsheet | |
Declare declare -a array=('a' 'b' 'c') | |
Length ${#array[@]} | |
Indices ${!array[@]} | |
Push n (append) array+=('i_0' ... 'i_n') | |
Pop n (bash>=4) unset 'array[-n]' | |
Pop n (bash<4) unset 'arr[${#arr[@]}-n]' | |
Shift n array=("${array[@]:n}") | |
Unshift n array=("i_0" ... "i_n" "${array[@]:n}") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment