Emacs, scripting and anything text oriented.

Escaping dollar signs in tcsh

Kaushal Modi

I found how to escape a $ sign in a regex expression in a tcsh alias. BUT it is UGLY!

I wanted to set an alias for a find command containing the -regex switch. For simplicity I will use this example:

find . -type f -regex '.*\.txt$'

This expression simply gives a list of all *.txt files in any directory under the current path.

The above command works fine when running in the terminal, but when saving that to a tcsh alias, that $ needs to be escaped:

alias findtxt "find . -type f -regex '.*txt'\"\$"''"

A simple $ has to be written as '\"\$"'!!!

Granted that I will usually get the same result if I did alias findtxt "find . -type f -regex '.*txt'" instead. But this turned out to be an interesting exercise on how to escape a $.

Reference

If you have written a response to this, enter your response post's URL below.

Or, you can send a "comment" webmention (it's OK if you don't know what that means). When asked about your website on an IndieAuth login screen, simply type https://commentpara.de.

Markdown Support**bold**, _italics_, ~~strikethrough~~, [descr](link), `monospace`, ```LANG\nline1\nline2\n``` (Yep, multi-line code blocks too, with syntax highlighting!), auto-hyperlinking.

Webmentions #