Shell script output with unix line endings

Whenever I use script() for creating a log it always creates dos line endings, unless I'm missing some option.

I know I can convert using tr or dos2unix, but is there any way to automatically generate output the way I want?
 
What is happening is that when you press Enter, it gets recorded also (0x0d characters). This is stated in the section bugs of the man page: "The script utility places everything in the log file, including line feeds and backspaces. This is not what the naive user expects." You pressing Enter = line feed = 0x0d

To eliminate the 0x0d characters, you can do this:

Code:
tr -d '\r' < typescript > typescript.ok

Where typescript is the file generated by script() and typescript.ok is a new file without the 0x0d characters (or line feeds, or enters).
 
If the script command is the same as in linux, then no, it defaults to DOS line endings and you will need to run it through a filter like tr or dos2unix. \r\n is not only the DOS newline but it is also kind of a standard in internet text protocol RFCs. This is a holdover from the days of electro-mechanical teletypes where the print head needed to be repositioned to column zero and the paper needed to advance one line.

Another annoyance of script is that it saves (verbatim) all keyboard text, so if you enter control characters or <DEL> then those are also part of the output.
 
If the script command is the same as in linux, then no, it defaults to DOS line endings and you will need to run it through a filter like tr or dos2unix. \r\n is not only the DOS newline but it is also kind of a standard in internet text protocol RFCs. This is a holdover from the days of electro-mechanical teletypes where the print head needed to be repositioned to column zero and the paper needed to advance one line.

Another annoyance of script is that it saves (verbatim) all keyboard text, so if you enter control characters or <DEL> then those are also part of the output.
I wouldn't personally consider that annoying, the whole point of the utility is to capture everything that goes on so that you can later use it to write a script based on what you did. If it ignored things like <DEL> then it would have to work out which times it was important and which times it wasn't.
 
Back
Top