This question already has an answer here:
- Concatenating strings in bash overwrites them 4 answers
My bash code file.sh
:
username=$1
pkgpath="/home/${username}_tmp.txt"
echo $username
echo $pkgpath
Now running the script with the command bash file.sh abc
should produce the result :
abc
/home/abc_tmp.txt
But the output I'm getting is :
abc
_tmp.txtc
Can someone explain why is this behavior occurring and how to obtain the desired result ?
EDIT
I'd like to mention that using pkgpath="/home/${username}"
gives me /home/abc
(desired) but running pkgpath="${username}_tmp.txt"
gives me _tmp.txt
(weird).