Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is it possible to echo out a string in tcsh such that it is fully escaped, as tcsh would understand? In the same way as printf %q works in bash:

% # Create a variable containing a tab character
% MYMONKEY=$'my\tmonkey'
% printf %q "$MYMONKEY"

Which can then be used to re-input the variable into bash. Anyone know of anything similar in tcsh?

share|improve this question
I've usually had to write a filter program (sed script) for just such a purpose. – mdpc Feb 13 '13 at 17:53

Workaround idea:

in tcsh

set MYMONKEY="my\tmonkey"

Note you do not add a "\n" at the end so the output will reflect this decision:

 printf "%s" $MYMONKEY

 to fix it you can use 

 printf "%s\n" $MYMONKEY


 printf $MYMONKEY
 my      monkey_My_Login_Name_@myhost>_

 my      monkey
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.