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

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

print variable in bash

#!/bin/bash  
echo  
echo "When single quote is used with string:"  
invitation='Welcome to javatpoint'  
echo $invitation  
echo  
echo "When double quote is used with string:"  
invitation="Welcome to javatpoint"  
echo $invitation  
echo  
echo "When variable is used with double quote:"  
Remark="Hello User!, $invitation"  
echo $Remark  
echo  
echo "When variable is used with single quote:"  
Remark='Hello User!, $invitation'  
echo $Remark  
echo  
Comment

PREVIOUS NEXT
Code Example
Shell :: linux unpack zip 
Shell :: django activate shell 
Shell :: install vuex orm 
Shell :: powershell string with quotes 
Shell :: supertest npm 
Shell :: ion2 calendar 
Shell :: heroku remove branch 
Shell :: mono-complete arch 
Shell :: powershell import module 
Shell :: linux install icloud 
Shell :: docker for ubuntu 
Shell :: edit text file bash 
Shell :: apt get update upgrade linux 
Shell :: connect to wifi with wpa_supplicant 
Shell :: add user centos 7 sudo 
Shell :: git installing in linux 
Shell :: grep a string in txt file 
Shell :: restore git stash 
Shell :: ubuntu start sublime 3 
Shell :: enable site 
Shell :: git abandon untracked files 
Shell :: get ip address linux 
Shell :: github readme images 
Shell :: install ubuntu on wsl 
Shell :: git ignore all files and folders in folder 
Shell :: uninstall package with yarn 
Shell :: hobo list services 
Shell :: Copy local repository for remote servers git 
Shell :: how to get all avd names in cmd 
Shell :: Sending a Simple Email From Linux Terminal 
ADD CONTENT
Topic
Content
Source link
Name
9+5 =