-
Array - Get last element of an array in linux shell In this article we learn about how to get last element of an array in linux shell in linux terminal. We can use negative index: 1 arr=( usdt btc eos ) 2 echo "${arr[-1]}" 1 arr=( usdt btc eos ) 2 echo "${arr[-2]}" 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 - Create an simple array in linux terminal In this article we can learn how to declare/define/create an array in linux commandline terminal. method1) using direct index values: usage: 1 array[value]="element" examples: 1 arrayNames[0]="btc" 2 arrayNames[1]="usdt" 3 arrayNames[2]="eth" 4 echo "${arrayNames[@]}" …
Read More -
Array - Display all elements in a array in linux In this article we can learn how to display each element in a array using for loop in linux terminal 1 arrayNames=( btc usdt eos eth ) 2 for names in "${arrayNames[@]}" 3 do 4 echo "$names" 5 done Display all the elements in an array: 1 arrayNames=( btc usdt eos eth ) 2 …
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 - Display length of the specific element in linux shell In this article we can learn how to display character count in a array element in linux bash shell and Display character count in a array element. Character count in 1st element: 1 arrayNames=( btc eos eth usdt ltc) 2 echo ${#arrayNames[1]} Character count …
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