[sf-lug] script(1) - and all that goop in the output Re: NEED INFO ABOUT BOOT SECTOR, SPACE LIMITS

Michael Paoli Michael.Paoli at cal.berkeley.edu
Wed Aug 2 06:33:13 PDT 2017


I'll often:
First of all, use an unsnazzy prompt, e.g.:
PS1='$ '
or
PS1='# '
And also, to semi-reasonably filter script(1) output file:
col -b | expand
Can (as you suggest), also trim out trailing \r before \n,
e.g.:
sed -e 's/^M$//'
Where that ^M is actually a single carriage return character,
not entered as ^ and M, but typically (from bash shell CLI)
entered as control-V control-M
Additionally, when using script(1), rather than using
vi(1) (or vim(1) or emacs(1)), use ex(1) or ed(1) to edit files.  :-)
I pretty commonly do that when saving the output for
education/training purposes ... or just want the edit session to be
much more readable, for whatever purpose(s).

Also if one does vi(1) or emacs(1) style command-line editing
in shell under script(1), can be useful to produce an additional
"final" (or near final) full output of that line before executing
it - so at least there will be a good clean nice readable version
in the script(1) output file.  With bash(1) and similar shells,
in command line edit mode, one can use control-L to redraw the
line, or likewise in edit mode, give the command #
which will insert it into the history as a comment and
output/display the line thusly at the same time.
Sometime sprinkling in something like:
$ fc -l -1
can also be handy to show/emphasize exactly what was given as
the final command.

> From: "Akkana Peck" <akkana at shallowsky.com>
> Subject: Re: [sf-lug] NEED INFO ABOUT BOOT SECTOR, SPACE LIMITS
> Date: Mon, 31 Jul 2017 11:29:41 -0600

> Alex Kleider writes:
>> Not being familiar with 'script' I gave it a try with the following results:
> [ ... ]
>> My question is why all the '^M's and '^['s?  (..representing control
>> characters I assume.) The output would be better off without them, me
>> thinks.
>
> Script stores everything the terminal sees, which includes carriage
> returns (ctrl-M) in addition to the line feeds (ctrl-J) that Linux/Unix
> normally uses as its newline character. Ctrl-[ is the escape
> character; you're seeing it because you have escape sequences
> in your prompt, maybe to colorize it or make it bold.
>
> I agree that mostly they get in the way. Of course you can remove
> them after the fact. For instance, you could run through through sed:
>
> sed -r -e 's/\r//g' -e 's/\x1b/<ESC>/g'
>
> (\r is the return character, 1b is hex for the escape character).




More information about the sf-lug mailing list