comando “script” salva letras desnecessárias

0

Ao usar o script para salvar toda a saída do terminal, vejo caracteres estranhos nos arquivos salvos, como [K , [0m , [KM , [C , para citar alguns. Embora eu cat ou more do arquivo eu pareça não ver isso, é o arquivo salvo que eu compartilho com os outros, então eu gostaria de saber se há uma maneira de não incluí-los sem hacks.

$ script --version
script from util-linux 2.27.1
$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 16.04.3 LTS
Release:        16.04
Codename:       xenial

$ script -a foo.log

Conteúdo do arquivo salvo:

Script started on Tue 10 Oct 2017 08:31:04 AM PDT
npasta@pasta-p50:~/link/marinara/periodic_sweetfish/201710_sweetfish$ 
(reverse-i-search)'': [K
[49@npasta@pasta-p50:~/link/marinara/periodic_sweetfish/201710_sweetfish$[C
[Knpasta@pasta-p50:~/link/marinara/periodic_sweetfish/201710_sweetfish$ cd pickles_ogre4_log_20171010083250_
_v0.0.7/
npasta@pasta-p50:~/link/marinara/periodic_sweetfish/201710_sweetfish/taptwo_ogre4_log_20171010083250_v0.0
0.7$ ll
total 1.2G
drwxrwxr-x 4 npasta npasta 4.0K Oct 10 08:36 [0m[01;34m..[0m/
drwxrwxr-x 3 npasta npasta 4.0K Oct 10 08:35 [01;34m.[0m/
-rw-rw-r-- 1 npasta npasta 122M Oct 10 08:33 ballers_sys.log.tgz_20171010083250
drwxrwxr-x 3 npasta npasta 4.0K Oct 10 08:32 [01;34mhome[0m/
-rw-r----- 1 npasta npasta 125M Oct 10 08:32 ballers.log.1_20171010083250
-rw-r----- 1 npasta npasta 3.3M Oct 10 08:32 ballers.log_20171010083250
-rw-r----- 1 npasta npasta  97M Oct 10 08:32 ballers.log.2_20171010083250
-rw-r----- 1 npasta npasta 154M Oct 10 08:32 ballers.log.3_20171010083250
-rw-r----- 1 npasta npasta 114M Oct 10 08:32 ballers.log.4_20171010083250
-rw-r----- 1 npasta npasta 114M Oct 10 08:32 ballers.log.5_20171010083250
-rw-r----- 1 npasta npasta 132M Oct 10 08:32 ballers.log.6_20171010083250
-rw-r----- 1 npasta npasta 157M Oct 10 08:32 ballers.log.7_20171010083250
-rw-r----- 1 npasta npasta  27M Oct 10 08:32 syslog.1_20171010083250
-rw-r----- 1 npasta npasta 736K Oct 10 08:32 syslog_20171010083250
-rw-r----- 1 npasta npasta  27M Oct 10 08:32 syslog.2_20171010083250
-rw-r----- 1 npasta npasta  27M Oct 10 08:32 syslog.3_20171010083250
-rw-r----- 1 npasta npasta  26M Oct 10 08:32 syslog.4_20171010083250
-rw-r----- 1 npasta npasta  27M Oct 10 08:32 syslog.5_20171010083250
-rw-r----- 1 npasta npasta  27M Oct 10 08:32 syslog.6_20171010083250
-rw-r----- 1 npasta npasta  27M Oct 10 08:32 syslog.7_20171010083250
npasta@pasta-p50:~/link/marinara/periodic_sweetfish/201710_sweetfish/taptwo_ogre4_log_20171010083250_v0.0
0.7$ M
(reverse-i-search)'': [K

[KM[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[Ca': cd taptwo_ogre4_log_20171010083250_v0.0.7/[5Pc': ack-grep -B 1 -A 1 -i "image wait" .
[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[1@k[C[C[C[1@-[C[C[C
npasta@pasta-p50:~/link/marinara/periodic_sweetfish/201710_sweetfish/taptwo_ogre4_log_20171010083250_v0.0
0.7$ ack-grep -B 1 -A 1 -i "image wait" .
[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[Kdisconnudisconnsdisconnbdisconn disconn[C[C[C[C[C[C[C" .
npasta@pasta-p50:~/link/marinara/periodic_sweetfish/201710_sweetfish/taptwo_ogre4_log_20171010083250_v0.0
0.7$ [H[Jnpasta@pasta-p50:~/link/marinara/periodic_sweetfish/201710_sweetfish/taptwo_ogre4_log_20171010083250_v0.0
0.7$ cd ..
npasta@pasta-p50:~/link/marinara/periodic_sweetfish/201710_sweetfish$ ls
20171001_auburnhills_proto4.log  [0m[01;35mIMG_20171001_133255.jpg[0m
20171001_auburnhills_proto5.log  [01;35mIMG_20171002_113137.jpg[0m
    
por IsaacS 11.10.2017 / 19:49

1 resposta

0

script salva todo o histórico do terminal, incluindo caracteres de controle, de modo que itens como alterações de cor, retrocessos e atualizações de barra de título por meio de sequências de controle de terminal sejam preservados. Quando você cat os caracteres de controle são interpretados pelo terminal porque eles não são visíveis após o fato.

Se você deseja apresentar o resultado final, tente recriar o script em perl mostrado em esta resposta relevante .

    
por 11.10.2017 / 19:55