I'm trying to delete range of array element but it's fail..
My array
root@ubuntu:~/work# echo ${a[@]}
cocacola.com airtel.com pepsi.com
Print 0-1 array looks ok
root@ubuntu:~/work# echo ${a[@]::2}
cocacola.com airtel.com
Now I'm trying to delete only these element using :
root@ubuntu:~/work# unset a[@]::2
root@ubuntu:~/work# echo ${a[@]}
It's delete whole array..
What I'm doing wrong ?
I found other way of deleting range of array but why above things is not working ?
for ((i=0; i<2; i++)); do unset a[$i]; done
EDIT
I had also tried but no luck
unset -v 'a[@]::2'
Asked by Rahul Patil
(25515 rep)
Apr 30, 2013, 04:02 PM
Last activity: Jul 28, 2025, 04:59 PM
Last activity: Jul 28, 2025, 04:59 PM