Search
 
SCRIPT & CODE EXAMPLE
 

SHELL

get length of array bash

## define it
distro=("redhat" "debian" "gentoo")
 
## get length of $distro array
len=${#distro[@]}
 
## Use bash for loop 
for (( i=0; i<$len; i++ )); do echo "${distro[$i]}" ; done
Comment

bash size of array

echo "${#my_array[@]}"
Comment

array length bash

echo "${#your_array[@]}"
Comment

bash length of array

# Basic syntax:
YOUR_VAR=( $YOUR_VAR ) # convert the string to an array
echo ${#YOUR_VAR[*]} # use the standard bash syntax to get the length of arrays

# Example usage:
YOUR_VAR='some string with words'
YOUR_VAR=( $YOUR_VAR )
echo ${#YOUR_VAR[*]}
--> 4

# Note, to convert the array back to a string, use:
YOUR_VAR="${YOUR_VAR[*]}"
Comment

PREVIOUS NEXT
Code Example
Shell :: pip install pygame 
Shell :: search file in linux terminal 
Shell :: manjaro nodejs 
Shell :: terminal not opening ubuntu 
Shell :: list file in tar archive 
Shell :: show ip address linux 
Shell :: linux port 
Shell :: rename python3 to python 
Shell :: error: cannot run ssh: No such file or directory 
Shell :: how to install jupyter 
Shell :: connect to a pod 
Shell :: check nativescript version 
Shell :: linux bash clear log file space 
Shell :: install kind 
Shell :: docker execute command in container 
Shell :: yarn start --reset-cache 
Shell :: shell load file as variable 
Shell :: how to check the parent branch in git 
Shell :: upgrade bash version mac 
Shell :: get newest version of original in own fork 
Shell :: .gitignore not working 
Shell :: 10 digit validation in jquery 
Shell :: image converter linux 
Shell :: ssh vs gpg keys 
Shell :: git no ssl verify 
Shell :: Failed to install the following Android SDK packages as some licences have not been accepted. build-tools;28.0.3 Android SDK Build-Tools 28.0.3 platforms;android-29 Android SDK Platform 29 
Shell :: rails scaffold 
Shell :: expo channels list 
Shell :: install typeorm node 
Shell :: install sweetlalert angular 
ADD CONTENT
Topic
Content
Source link
Name
1+9 =