-
-
Save andrwj/3d6e9918e97105f2dec19b780929091f to your computer and use it in GitHub Desktop.
Zsh and Bash Array Shift (remove first item from the Array)
This file contains 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
array=(foo, bar, baz) | |
echo ${array[@]} # => foo, bar, baz | |
array=("${array[@]:1}") | |
echo ${array[@]} # => bar, baz | |
array=("${array[@]:1}") | |
echo ${array[@]} # => baz |
This file contains 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
array=(foo, bar, baz) | |
echo $array # => foo, bar, baz | |
array=("${(@)array:1}") | |
echo $array # => bar, baz | |
array=("${(@)array:1}") | |
echo $array # => baz | |
# UPDATE: this works as well and is less confusing syntax | |
array=(${array:1}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment