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 :: error: RPC failed; curl 56 GnuTLS recv error (-110): The TLS connection was non-properly terminated. 
Shell :: install apache di linux 
Shell :: brew on windows 
Shell :: microstack.openstack to openstack 
Shell :: windows cmd shortcut that always opens as administrator 
Shell :: Cannot open: https://centos7.iuscommunity.org/ius-release.rpm. Skipping 
Shell :: k8s dashboartd 
Shell :: where do you install composer 
Shell :: unix rename file 
Shell :: powershell computer information 
Shell :: install docker compose on centos 
Shell :: configure: error: "curses not found" 
Shell :: create a new git branch 
Shell :: vs code wsl unable to write file 
Shell :: get file until match without including 
Shell :: How to use Git for Unity3D source control? 
Shell :: cannot find lstdc++ ubuntu 
Shell :: gufw ubuntu install 
Shell :: how to highlight code in github editor 
Shell :: github portfolio 
Shell :: linux move everything except 
Shell :: kube dashboard expose access port 
Shell :: venv git 
Shell :: gzip multiple files at once 
Shell :: powershell command shutdown computer 
Shell :: powershell github 
Shell :: close adb server 
Shell :: ubuntu command line change line in file 
Shell :: ssh key exchange 
Shell :: linux count lines csv files 
ADD CONTENT
Topic
Content
Source link
Name
4+6 =