Search
 
SCRIPT & CODE EXAMPLE
 

SHELL

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[*]}"
Comment

PREVIOUS NEXT
Code Example
Shell :: install webstorm ubuntu 20.04 
Shell :: export variable bash 
Shell :: The terminal process failed to launch: Path to shell executable "cmd.exe" does not exist. vscode 
Shell :: icon theme and widget ubuntu 
Shell :: merging branches in git 
Shell :: redis delete key 
Shell :: docker rmi dangling=true 
Shell :: how to activate virtual environment in ubuntu 
Shell :: bash script command not found 
Shell :: @material-ui/icons 
Shell :: gitlab clone with username and password 
Shell :: big sur ERROR: Error installing ffi: ERROR: Failed to build gem native extension. 
Shell :: how to uninstall slick-carousel 
Shell :: how to increase font size in elementary os 
Shell :: find exclude 
Shell :: git pull onbly submodule 
Shell :: unix terminal search inside file 
Shell :: linux shell parameter 
Shell :: install ssl certificate ubuntu nginx 
Shell :: wsl2 vs virtualbox performance 
Shell :: find all .desktop files linux 
Shell :: batch fork bomb 
Shell :: how to view hidden files and folders on terminal 
Shell :: setting docker as a non root user 
Shell :: github push local branch to remote 
Shell :: push the project to github 
Shell :: how to ssh in termux 
Shell :: setup systemd redis 
Shell :: what version of linux am i running 
Shell :: linux bash temporary file 
ADD CONTENT
Topic
Content
Source link
Name
2+5 =