-
Array - Get element values at specific starting position in linux bash shell In this article we can learn how to output the elements in specific starting position in linux bash shell. 1e.g: starting at second element 2 arrayNames=( btc eos eth usdt ltc) 3 echo ${arrayNames[@]:1} 1e.g: starting at fourth element 2 …
Read More -
Array - Remove elements from a linux shell array In this article we can learn how to delete/remove elements/indexes from an linux bash shell array. The following way can remove an array element completely: 1 arr=(eth eos btc usd etc) 2 delete=2 3 arr=( "${arr[@]:0:$delete}" "${arr[@]:$(($delete+1))}" ) 4 echo …
Read More -
Array - Replace elements or replace matched words in linux shell array In this article we can learn how to replace elements,words,characters in linux bash shell arrays. usage: echo ${array[@]//substring/replacedstring} example1) Remove 'ltc' then replace 'bch': 1e.g: 2 arrayNames=( btc eos eth usdt ltc) 3 echo …
Read More -
Array - Get Number of elements in a array in linux terminal In this article we can learn how to Display elements count in a array in linux terminal shell. 1 arrayNames=( btc eos eth usdt ltc) 2 echo ${#arrayNames[@]} OR: 1 arrayNames=( btc eos eth usdt ltc bch) 2 echo ${#arrayNames[*]} Helpful links: …
Read More -
Array - Add new elements to an array using linux terminal In this article we can learn how to add/create new elements in an array push elements to a array without elements index in linux terminal bash. Push elements to a array without elements index On linux shells arr[0]="new" and arr[1]="newest" methods are not …
Read More -
Array - Display elements in a range in linux shell In this article we can learn how to display elements in a specific range in linux terminal shell. Index 2 to 4: 1 arrayNames=( btc eos eth usdt ltc) 2 echo ${arrayNames[@]:2:4} Index 1 to 3: 1 arrayNames=( btc eos eth usdt ltc) 2 echo ${arrayNames[@]:1:3} Helpful …
Read More -
Array - Access each elements in a array using for loop in linux In this article we can learn how to traverse through the array elements we can use for loop in linux 1 arrayNames=( way test auth new ) 2 for names in "${arrayNames[@]}" 3 do 4 echo "array elements : $names" 5 done Helpful Links: …
Read More