Question : save output of command to craible bash
Answered by : thelazylemur
password=$(openssl rand -base64 32)
echo $password
Source : | Last Update : Fri, 13 Nov 20
Question : save output of command to variable bash
Answered by : distinct-dormouse-os81suftn8yv
OUTPUT="$(ls -1)"
echo "${OUTPUT}"
MULTILINE=$(ls \ -1)
echo "${MULTILINE}"
Source : https://stackoverflow.com/questions/4651437/how-do-i-set-a-variable-to-the-output-of-a-command-in-bash | Last Update : Mon, 11 May 20
Question : store printed output in variable bash
Answered by : armando-flores
#For storing and printing output at the same time do following:
OUTPUT=$(ls -1) #First assign output of command execution to a variable
echo "${OUTPUT}" #Then print out the result in variable into the terminal
Source : | Last Update : Thu, 24 Dec 20
Question : shell script store command output in variable
Answered by : armando-flores
#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
Source : | Last Update : Tue, 15 Dec 20