'dos2unix' is unable to convert a `typescript` file to Unix format

typescript saves everything what is sent to your terminal which may include escape sequences for positioning, colors, brightness etc. (0x1B is the ESC character.) The terminal output contains CR and LF even if the usual line ending in text files is different.

The character 0x1B makes dos2unix assume your input might be a binary file. Because modifying a binary file might not be useful, dos2unix rejects to do this by default. Apart from this there is no problem with the escape character.

You can try dos2unix -f to force conversion of the seemingly binary file. This way you tell it that you know that modifying the line endings in this file is safe.

Or use vim to remove the CR characters. :%s/CTRL+V CTRL+M ENTER

In case there might be more than one CR per line :%s/CTRL+V CTRL+M//g ENTER


0x1b should be part of a VT100 terminal color code or similar.

http://www.termsys.demon.co.uk/vtansi.htm

<ESC> represents the ASCII "escape" character, 0x1B.

In general what script records is not what you see but what the terminal sees, so it's a raw terminal recording. It can even record timing information for scriptreplay to show what was going on in the same speed it originally happened...

And raw terminal just uses \r to move the cursor to the left. Even though it's no longer used in plain text files, it's still very much present in terminals. There's \r everywhere, it's just that it's invisible to you most of the time.

If you go through the kernel sources, you can find things like this:

static void puts_raw_fixed(int (*puts_raw) (const char *s, int len),
                           const char *s, int count)
{
        const char *s1;

        /* Output '\r' before each '\n' */
        while ((s1 = memchr(s, '\n', count)) != NULL) {
                puts_raw(s, s1 - s);
                puts_raw("\r\n", 2);
                count -= s1 + 1 - s;
                s = s1 + 1;
        }
        puts_raw(s, count);
}

Consider it a technical implementation detail of terminals and the like... and try to ignore it (as long as you don't do fancy terminal things).

If you don't want a raw recording, perhaps use the good old command > output.txt redirection instead of script, or simply... copy & paste from the terminal itself. That should produce output that is free of \r, unless the command itself produced raw data like that.

Otherwise perhaps see this question on Removing control chars (including console codes / colours) from script output for post-processing typescript files. Results might vary however. There's a lot of stuff going on in a terminal without you realizing, and script records it all.