
使用するときスクリプト端末出力をすべて保存しようとしたファイルに、など、奇妙な[K
文字[0m
が表示されます[KM
。このファイルや私のファイルが見えないよう[C
ですが、他の人と共有するセーブファイルなので、ハッキングなしで含めないようにする方法がないかと思います。cat
more
$ 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
保存されたファイルの内容:
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
答え1
script
制御文字を含む完全な端末履歴が保存されるため、端末制御シーケンスで行われた色の変更、バックスペース、タイトルバーの更新などが保存されます。制御文字はcat
後で表示されないため、使用時に端末で解釈されます。
最終結果を提示するには、以下のようにPerlスクリプトを再作成してください。この関連回答。