“output perintah script store dalam variabel” Kode Jawaban

Simpan output perintah ke craible bash

password=$(openssl rand -base64 32)
echo $password
TheLazyLemur

Simpan output perintah ke bash variabel

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

MULTILINE=$(ls \
   -1)
echo "${MULTILINE}"
Distinct Dormouse

Simpan output cetak dalam bash variabel

#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
Armandres

output perintah script store dalam variabel

#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
Armandres

Jawaban yang mirip dengan “output perintah script store dalam variabel”

Pertanyaan yang mirip dengan “output perintah script store dalam variabel”

Lebih banyak jawaban terkait untuk “output perintah script store dalam variabel” di Shell/Bash

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya