2

如果我运行这个命令:

traceroute -p 80 www.google.com. 2>&1|tee -a ~/tmp/traceroute.log

终端内容与文件内容一致,干净(无特殊字符)

但是,如果我运行此命令:

watch -n5 "traceroute -p 80 www.google.com." 2>&1|tee -a ~/tmp/watch.log

我在终端看到这个:

Every 5.0s: traceroute -p 80 www.google.com.            Fri Jan 18 11:27:41 2013

traceroute to www.google.com. (74.125.237.115), 30 hops max, 60 byte packets
 1  10.0.0.1 (10.0.0.1)  3.138 ms  3.351 ms  3.349 ms
 2  192.168.1.254 (192.168.1.254)  5.832 ms  6.043 ms  6.183 ms
 3  lback9.comcen.com.au (203.23.236.9)  31.569 ms  31.949 ms  33.484 ms
 4  core-syd-lns2.comcen.com.au (203.23.236.45)  48.331 ms  48.484 ms  48.720 ms
 5  * * *`

这在日志文件中(SE 代码解析/显示阻塞如下):

(B)0[?1049h[1;24r[m[4l[H[JEvery 5.0s: traceroute -p 80 www.google.com.[1;57HFri Jan 18 11:27:41 2013[3;1Htraceroute to www.google.com. (74.125.237.115), 30 hops max, 60 byte packets
[1B 1  10.0.0.1 (10.0.0.1)  3.138 ms  3.351 ms  3.349 ms

[1B 2 192.168.1.254 (192.168.1.254) 5.832 ms 6.043 ms 6.183 ms [1B 3 lback9.comcen.com.au (203.23.236.9) 31.569 ms 31.949 ms 33.484 ms [1B 4 core-syd-lns2.comcen.com .au (203.23.236.45) 48.331 毫秒 48.484 毫秒 48.720 毫秒[8;2H5 * * * [1B 6 * * *

我检查了我的语言环境设置,并将它们粘贴到~/.bashrc

~$ locale
LANG=en_US.UTF-8
LANGUAGE=
LC_CTYPE="en_US.UTF-8"
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_COLLATE="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_PAPER="en_US.UTF-8"
LC_NAME="en_US.UTF-8"
LC_ADDRESS="en_US.UTF-8"
LC_TELEPHONE="en_US.UTF-8"
LC_MEASUREMENT="en_US.UTF-8"
LC_IDENTIFICATION="en_US.UTF-8"
LC_ALL=en_US.UTF-8

并在~/.bashrc

export LC_ALL="en_US.UTF-8"
export LANG="$LC_ALL"
export LANGUAGE="$LC_ALLL"
export LC_CTYPE="$LC_ALL"
export LC_NUMERIC="$LC_ALL"
export LC_TIME="$LC_ALL"
export LC_COLLATE="$LC_ALL"
export LC_MONETARY="$LC_ALL"
export LC_MESSAGES="$LC_ALL"
export LC_PAPER="$LC_ALL"
export LC_NAME="$LC_ALL"
export LC_ADDRESS="$LC_ALL"
export LC_TELEPHONE="$LC_ALL"
export LC_MEASUREMENT="$LC_ALL"
export LC_IDENTIFICATION="$LC_ALL"

有没有人了解导致这种情况的原因?

4

1 回答 1

1

Watch 每次显示新信息时都会清除屏幕。它通过打印到终端的特殊字符来做到这一点。在文件中,您只是看到这些字符被完全解释。如果您想看到真正的混乱,请尝试打开手表的一些其他功能,例如 --differences 突出显示。

于 2013-01-18T00:59:37.763 回答