Search
 
SCRIPT & CODE EXAMPLE
 

SHELL

save output of command to variable bash

OUTPUT="$(ls -1)"
echo "${OUTPUT}"

MULTILINE=$(ls 
   -1)
echo "${MULTILINE}"
Comment

store result of command in variable bash

variable=$(command [option…] argument1 arguments2 …)
Comment

bash store script output in variable

#Just use following structure to store output of command into a variable:
var=$(command)
#For example:
var=$(echo 'hi')	#store hi into var
var=$(ls)	#store list of files into var
Comment

PREVIOUS NEXT
Code Example
Shell :: bash store pipe output in variable 
Shell :: video not working linux 
Shell :: installing haskell command 
Shell :: hard link linux 
Shell :: angular reduce vendor.js size 
Shell :: linux command to open a file 
Shell :: download a file using curl 
Shell :: docker compose stdin_open 
Shell :: how to check version of package centos 
Shell :: how to install mvnw 
Shell :: camera for linux 
Shell :: git use cat instead of less 
Shell :: change default branch on git 
Shell :: list file sizes 
Shell :: bash get unique lines 
Shell :: android get armeabi 
Shell :: debian md5sum: command not found 
Shell :: linux how to write to file 
Shell :: install dbeaver using snap 
Shell :: download chromium-browser/libffmpeg.so 
Shell :: where are dns entries on linux 
Shell :: inicializar as credenciais no git 
Shell :: hsdpa modem software for linux 
Shell :: install gh 
Shell :: download istioctl 
Shell :: powershell ssh with password 
Shell :: move all files in subdirectories to current directory linux 
Shell :: create vue app locally 
Shell :: list hdfs running linux 
Shell :: git delete master branch and recreate 
ADD CONTENT
Topic
Content
Source link
Name
9+1 =