Remove the last element from an array

前端 未结 6 1251
甜味超标
甜味超标 2020-12-13 08:55

I want to remove the last entry in my array, and I want the array to show me that it has 1 less entry when I am using the ${#array[@]}. This is the current line

6条回答
  •  难免孤独
    2020-12-13 09:31

    In your function, you could add the following:

    target="${@:$(($#)):1}"
    set -- "${@:1:$(($#-1))}"
    

提交回复
热议问题