“Array -Länge der Array” Code-Antworten

Holen Sie sich die Länge der 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
Smiling Spider

Bash -Größe des Arrays

echo "${#my_array[@]}"
Powerful Pollan

Array -Länge der 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[*]}"
Charles-Alexandre Roy

Ähnliche Antworten wie “Array -Länge der Array”

Fragen ähnlich wie “Array -Länge der Array”

Weitere verwandte Antworten zu “Array -Länge der Array” auf Shell/Bash

Durchsuchen Sie beliebte Code-Antworten nach Sprache

Durchsuchen Sie andere Codesprachen