1

What's the best way to printf an exclamation point in tcsh?

It seems like using single or double quotes has no effect on escaping the exclamation point; and using a backspace does work, but then it disappears from the history.

  • 1
    What command did you run? printf '%s\n' ! seems to work normally. – cuonglm Sep 20 '14 at 16:37
  • Oh, so, the trick is to have ! all by itself, and use %s, instead of simply having ! inline? – cnst Sep 20 '14 at 17:53
0

Try:

$ printf 'a\!c\n'
a!c

or:

$ printf '%s\n' a\!c
  • This only works prior to using savehist and reloading tcsh. – cnst Sep 21 '14 at 15:34
0

tcsh uses the ! character for history substitution

g4ur4v:~> echo $0
tcsh
g4ur4v:~> printf '!\n'
!

EDIT

g4ur4v:~> echo 'a\!c'
a!c
g4ur4v:~> printf 'a\!c\n'
a!c
  • printf a!c... – cnst Sep 20 '14 at 17:56
  • added to the answer. – g4ur4v Sep 20 '14 at 18:29
  • This malfunctions with savehist -- after loading back the history, this extra \! becomes just !, and the thing stops working. – cnst Sep 21 '14 at 15:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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