How to remove the first element from an array in Bash

2 Answers

0 votes
arr=(a b c d e)

unset arr[0] 

echo ${arr[@]} 
 
 
 
   
# run:
#
# b c d e
#

 



answered Feb 12, 2021 by avibootz
0 votes
arr=(a b c d e)

arr=("${arr[@]:1}") 

echo ${arr[@]} 
 
 
 
   
# run:
#
# b c d e
#

 



answered Feb 12, 2021 by avibootz

Related questions

2 answers 338 views
1 answer 306 views
2 answers 404 views
1 answer 345 views
2 answers 300 views
1 answer 283 views
2 answers 587 views
...