Horje
bash number of elements in variable Code Example
bash number of elements in variable
# 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[*]}"




Shell

Related
git diff lines of code Code Example git diff lines of code Code Example
github track filename capitalisation Code Example github track filename capitalisation Code Example
bash Creating help function Code Example bash Creating help function Code Example
how to clone a repo with a different name Code Example how to clone a repo with a different name Code Example
samtools extract sequence from bam file Code Example samtools extract sequence from bam file Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
16