Some dumb questions born of frustration

Tim Chase blinux.list at thechases.com
Thu Oct 27 14:21:16 UTC 2016


On October 27, 2016, Janina Sajka wrote:
> Try the following:
> 
> PS1="\\\$"
> 
> I'm sorry, I don't recall the logic of the triple backslash.

Because you're using double-quotes, the stuff inside them is still
interpreted.  So the first backslash escapes the second backslash and
the third backslash escapes the "$" so that the assigned value is a
literal backslash followed by a literal "$".  In this particular
case, because nothing follows the "$" that could be interpreted as a
variable expansion, it would be safe to use

  PS1="\\$"

but I'd just recommend using single quotes instead of double-quotes
which prevents the escaping altogether:

  PS1='\$'

-tim






More information about the Blinux-list mailing list