Search
 
SCRIPT & CODE EXAMPLE
 

SHELL

bash variable in string

${!var}	#Just use to use reference value inside another variable ;)
Comment

bash use variable in string

domain='http://www.whitehouse.gov'
path='/some/path'
base_url="$domain$path"
Comment

Example of Bash Variable in String

echo "***Assigning a variable***"
Var_1="Softhunt"
echo "***Printing Var_1 which is assigned value of Softhunt.net***"
echo $Var_1
echo "***Printing Var_2 which is not assigned***"
echo "***Nothing gets printed!***"
Var_start="https://www."
Var_end=".net"
echo $Var_start$Var_1$Var_end
echo "***Sequence keyword will print 1 to 4 in different lines***"
seq 1 4
echo "***The following command will print it in single line***"
echo $(seq 1 4)
echo "***Arthmetical operator to add 2 numbers entered by users: 2 and 3"
echo $((2+3))
echo "***Using bc utility to restrict the number of decimals***"
echo "7.5 / 2.1" | bc
echo "***Using bc utility to not restrict the number of decimals***"
echo "7.5 / 2.1" | bc -l
Comment

PREVIOUS NEXT
Code Example
Shell :: cmd turn on wifi adapter 
Shell :: git remote branch 
Shell :: launch bash script at startup linux 
Shell :: python code in bash script 
Shell :: uninstall newrelic amazon linux 
Shell :: alter package body compile 
Shell :: install thefuck 
Shell :: unix touch all files recursively 
Shell :: linux modsecurity allow googlebot 
Shell :: shell current week 
Shell :: how to grep doi from RTF file 
Shell :: install new kernel ubuntu 20.04 
Shell :: using screen in wsl 
Shell :: how to fill text when create file in ubuntu 
Shell :: batch number comparison 
Shell :: unzip a zip file ubuntu 
Shell :: start brave with tor terminal 
Shell :: powershell add to path 
Shell :: rosetta terminal icon 
Shell :: fish add to path 
Shell :: how to install cs50 library in ubuntu 
Shell :: git rebase branch to master 
Shell :: fast backup mac 
Shell :: START/STOP MONGOD AS A SERVICE (MAC) 
Shell :: where do you install composer 
Shell :: list all files with extension lknux 
Shell :: curl time response 
Shell :: virtualbox extension pack linux 
Shell :: install jitsi on ubuntu 
Shell :: How to undo the most recent local commits in Git 
ADD CONTENT
Topic
Content
Source link
Name
2+4 =