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 :: docker prune images 
Shell :: kill intellij ubuntu 
Shell :: GIT - Cleaning ignored file when .gitignore added after changes 
Shell :: how to unistall and reinstall latest composer in mac 
Shell :: remote origin already exist error 
Shell :: nginx certbot ubuntu 
Shell :: install vscode using apt 
Shell :: install google chrome linux 
Shell :: vim ubuntu install 
Shell :: how to uncommit my last commit in git 
Shell :: install folium using anaconda 
Shell :: installing gnome tweak tool 
Shell :: install workbench on ubuntu 
Shell :: instalar tcpdump ubuntu 
Shell :: install pavucontrol ubuntu 20.04 
Shell :: ubuntu command to list largest files 
Shell :: how to pull and overwrite local changes git 
Shell :: open folder from terminal in kali 
Shell :: how to install git on aws linux 
Shell :: heroku command not found 
Shell :: uncommit last commit 
Shell :: git pull all branches at once 
Shell :: curl install pip 
Shell :: could not connect to server: No such file or directory Is the server running locally and accepting connections on Unix domain socket "/tmp/.s.PGSQL.5432"? 
Shell :: change git commit message 
Shell :: bash: npm: command not found 
Shell :: raspberry pi set wifi headless 
Shell :: if variable has substring in bash 
Shell :: flutter download all dependencies 
Shell :: delete empty files bash 
ADD CONTENT
Topic
Content
Source link
Name
5+2 =