How can I escape $
in csh? inside <double-quotes> (""
). I'm trying to do this but can't escape the <dollar> sign ($
)
alias e "echo \\!:2-$"
This works but is not enough for my needs
alias e echo \\!:2-$
The answers suggested to this old question aren't correct.
It can be done, in CSH and other shells, and regardless of the kind of quote, but you need to exit the double quotes first if using them, for some shells.
The following should work in (almost) all shells, so I use it for simplicity. I've used backquote to get the output of a command because it's simpler to follow and avoids needing to add extra "$" symbols (the more modern style). Note the different uses of "$", to actually get a variable and as a literal (inside and outside single quotes for ease).
This should work in most shells.
EXAMPLE COMMAND:
echo "My terminal is $term, first file found in /dev is </dev/`ls /dev | head -n 1`>, the
dollar symbol is '"`echo '$'`"', and a newspaper costs "`echo '$'`"2.50."
OUTPUT:
My terminal is xterm, first file found in /dev is </dev/acpi>, the dollar symbol
is '$', and a newspaper costs $2.50.