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 :: centos 7 openldap install 
Shell :: linux how many cores 
Shell :: search git history 
Shell :: git lines added and removed by author 
Shell :: how to setup vim plugins 
Shell :: create new repo 
Shell :: debian install ping 
Shell :: check gcc version in ubuntu 
Shell :: git cheat sheet 
Shell :: Curl default connect-timeout 
Shell :: powershell active directory script examples 
Shell :: bash path ubuntu 
Shell :: install kazam screencaster ubuntu 
Shell :: openjdk 1.8 mac brew 
Shell :: x11 development libraries 
Shell :: remove file from terminal ubuntu 
Shell :: can not ping github 
Shell :: ionic change app icon 
Shell :: install simplejwt django 
Shell :: command to add a user to a group 
Shell :: PowerShell read CSV file line by line 
Shell :: linux script to clean up log files in /var/log 
Shell :: php install extension 
Shell :: ubuntu 20.04 install repo 
Shell :: push particular commit in git 
Shell :: install polar linux 
Shell :: install redis 
Shell :: redis install ubuntu 20.04 
Shell :: install solana cli 
Shell :: zsh slow in git repo 
ADD CONTENT
Topic
Content
Source link
Name
6+7 =