I asked a question some time ago, about setting a csh variable to NL or
any special character. I got some answers, which greatly helped me come to
the following conclusions. I'm using SunOS 4.1.1 .
In fact, I had two problems: the first was to put a special character into
the variable, and the second one was to get the character from it.
1. How to put what I want into this $var
People used to SysV would think of
set var=`echo \ooo` (o=octal digit)
but the BSD echo doesn't recognize this syntax.
Hopefully I can do :
set var=`/usr/5bin/echo \\ooo`
One can also use tr (full BSD-compatible this time):
set var=`echo A | tr A \\ooo`
But the easiest, by far, is:
set var=^V^<char> e.g. set var=^V^H for a backspace
For tabs, you have to enclose the whole into single quotes:
set var="^V^I" (i.e., type ctrl-V then ctrl-I or TAB)
(here the ^V is necessary only when using tcsh, with which it means 'file
And for newlines, simply put:
This way, you don't use external commands.
2. How to use these characters
Let's try echo:
% set var = "^F"
% echo -n $var | od -x
It works, but when you want to display a $nl...
% echo -n $nl | od -x
(same result with a TAB)
Well, the trick is to use the :q modifier
INRIA Rocquencourt, projet Sabre
"Noel au balcon, Paques aux tisons"