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 :: monitor mode wifi kali 
Shell :: run google chrome from terminal 
Shell :: see what user a process is running as 
Shell :: linux find text in files recursively -include 
Shell :: check how many version installed on nvm package 
Shell :: multiple git stashes 
Shell :: change remote url github 
Shell :: npx pod update 
Shell :: install supervisor ubuntu 20.04 
Shell :: bash htop 
Shell :: remove git proxy local 
Shell :: foreach powershell 
Shell :: linux screen list 
Shell :: run cmd elevated command line 
Shell :: substring frequency 
Shell :: restart influxdb 
Shell :: Bash/Shell comment multiple lines 
Shell :: git log show branch of commit 
Shell :: linux my ip 
Shell :: docker compose current directory 
Shell :: linux require a password to open a certain file 
Shell :: make executable bash script 
Shell :: gradle threw an error while downloading artifacts from the network. retrying to download 
Shell :: How can I make LibreOffice look better? 
Shell :: apollo client install 
Shell :: dpkg: error processing archive /var/cache/apt/archives/atftpd_0.7.git20210915- 
Shell :: install memcache di linux 
Shell :: how to copy the content of the file to clipboard in bash 
Shell :: git stash with message 
Shell :: openssl p12 to pem 
ADD CONTENT
Topic
Content
Source link
Name
3+4 =