Search
 
SCRIPT & CODE EXAMPLE
 

SHELL

store printed output in variable bash

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

shell script store command 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 :: download office 365 for ubuntu 
Shell :: get only file names from CMD 
Shell :: import single table from mysql dump 
Shell :: git clone private repo 
Shell :: limit image size on github 
Shell :: brew cask specific version 
Shell :: sleep in linux command 
Shell :: git force push after reset 
Shell :: ubuntu fractional scaling 
Shell :: cmd file list to text 
Shell :: command to Change User Primary Group 
Shell :: git credentials store with timeout 
Shell :: remove all files in a directory linux 
Shell :: how to append string to file names in linux 
Shell :: shell get unique lines 
Shell :: step10 pgadmin ubuntu 20.04 
Shell :: how to kickstart ARD on mac using terminal 
Shell :: Find CentOS version and architecture 
Shell :: install nmap 
Shell :: opera libffmpeg.so 
Shell :: certbot apache subdomain 
Shell :: Git: Unexpected identifier git commit error 
Shell :: config php.ini for magento@ 
Shell :: How to remove Directories with rm 
Shell :: let latest commit hash 
Shell :: ubuntu bluetooth dongle not working 
Shell :: git buffer 
Shell :: upload local to remote ssh 
Shell :: create a doxygen config file 
Shell :: multiple commands one line linux 
ADD CONTENT
Topic
Content
Source link
Name
4+7 =