Reputation: 11
I wrote my own repo file and am attempting to script the installation in bash.
My code:
echo -e "[repo name]\nname=repo - $serverver - $basearch...\n.." >> /etc/yum.repos.d/reponame.repo
However when I run the command the $serverver
and $basearch
are missing.
How can I echo the variables into the file with out it trying to determine them?
I have attempted
echo -E
"$serverver"
'$serverver'
`$serverver`
\"$serverver\"
Upvotes: 1
Views: 2615
Reputation: 2082
echo -e "[repo name]\nname=repo - \$serverver - \$basearch...\n.." >> /etc/yum.repos.d/reponame.repo
$ denotes shell variable expansion. If you want a literal $ it has to be escaped, as above, or you must use single quotes. If you want to expand shell variables they must be defined, or else they will yield the empty string.
Upvotes: 2
Reputation: 11479
To add to yum.repos.d
use single quotes'
instead of double"
. That preserves the $
signs as it is which is later interpreted by yum
.
echo -e '[repo name]\nname=repo - $serverver - $basearch...\n..' >> /etc/yum.repos.d/reponame.repo
Upvotes: 2