maartenjan.dev

Hi! I'm Maarten-Jan, a Software Engineer focussed on Java, Kotlin, Event Sourcing and Kubernetes. I sometimes write down what I do.

Back to Bash Basics

Sometimes stuff's pretty simple if you think about it. Some password generating tool generated passwords using dollar signs ($). This caused some issues when typing in this password in the terminal, since the dollar is the starting point of a variable in bash... Important to keep the escaping rules of bash in mind, as shown in the example below.

One should type in a literal string with a $ always using single quotes!

#!/bin/sh
var=hoi
echo "$var" # hoi
echo '$var' # $var
echo "blaat$" # blaat$
echo "hoi$wontshow" # hoi