[TUHS] Literal character escapes in v7
Will Senn
will.senn at gmail.com
Tue Nov 7 15:00:03 AEST 2017
On 11/6/17 10:49 PM, Will Senn wrote:
> On 11/6/17 10:34 PM, arnold at skeeve.com wrote:
>> Will Senn <will.senn at gmail.com> wrote:
>>
>>> I'm not looking for code review, but the code is intended to replace
>>> the
>>> tabs and backspaces with \t and \b respectively, but I haven't been
>>> able
>>> to test it because I can't seem to make a backspace character appear in
>>> input. In later unices, ^V followed by the backspace would work, but
>>> that's not part of v7. Backspace itself is my erase character, so
>>> anytime I just type it, it backspaces :).
>> awk 'BEGIN { print "a\bc\td" ; exit }' | your-program
>>
>> Enjoy,
>>
>> Arnold
>>
>> P.S. The exit is needed for V7 awk, IIRC, not modern ones.
>
> This is a good idea, but... Here's my results from just running awk
> for \t, \n, and \b:
>
> $ awk 'BEGIN { print "a\tb" ; exit }';
> a b
> $ awk 'BEGIN { print "a\nb" ; exit }'
> anb
> $ awk 'BEGIN { print "a\bb" ; exit }'
> abb
> $
>
> Strange. It looks like it's just ignoring the backslash in the case of
> \n and \b.
>
> Will
>
I wrote a c program to print a string in line with the suggestion to use
awk and my code worked, but it's still odd that the above didn't work.
Will
--
GPG Fingerprint: 68F4 B3BD 1730 555A 4462 7D45 3EAA 5B6D A982 BAAF
More information about the TUHS
mailing list