dumb
inside your script session. Then your shell (and other programs) won't use any control sequences at all. However, in this case you cannot use screen-oriented programs like editors (ed(1) will work, though), and the editing functions of your shell will be very limited. Also, if your shell prompt does fancy things (like using colors or bold font), you'll have to reset it to something simpler.That's exactly what I'm trying to do.I assume by “ANSI characters” you mean control sequences used by the shell, editors and similar, right?
That's quite a difficult thing to do by software, because in order to remove them, they have to be interpreted – that is, the software has to implement a terminal renderer. The ansi2txt tool does exactly that, but it only supports a subset of VT100 control sequences. It probably won't work with other kinds of emulated terminals.
Depending on your actual use case, there are a few alternatives. For example, you can set the TERM environment variable todumb
inside your script session. Then your shell (and other programs) won't use any control sequences at all. However, in this case you cannot use screen-oriented programs like editors (ed(1) will work, though), and the editing functions of your shell will be very limited. Also, if your shell prompt does fancy things (like using colors or bold font), you'll have to reset it to something simpler.
env TERM=dumb
before starting script
? sh
-- this is needed, because AFAIK the tcsh shell does not allow for specifying control chars by octal or hex code sed -e "s|["$'\x01'"-"$'\x1F'"]| |g" -i ".back" test.txt
exit
-- to the normal interactive shell, presumably tcshIt has to be a single command:The TERM=dumb idea sounds useful, though not sure how to use it... Do I runenv TERM=dumb
before startingscript
?
env TERM=dumb script
export PS1='> '
, for example.