【发布时间】:2015-11-20 18:06:32
【问题描述】:
如果我跑:
$ ls -l /tmp
total 16
drwxr-xr-x 2 noaccess noaccess 177 Nov 18 09:53 hsperfdata_noaccess
drwxr-xr-x 2 root root 117 Nov 18 09:53 hsperfdata_root
我得到了预期的结果:
]$ ls -l /tmp | tr -s '[:space:]'
total 16
drwxr-xr-x 2 noaccess noaccess 177 Nov 18 09:53 hsperfdata_noaccess
drwxr-xr-x 2 root root 117 Nov 18 09:53 hsperfdata_root
然而tr 不会影响file 的输出:
$ file /tmp/dummy
/tmp/dummy: empty file
$ file /tmp/dummy | tr -s '[:space:]'
/tmp/dummy: empty file
(如果我使用[:blank:],则相同)
我期待:
$ file /tmp/dummy | tr -s '[:space:]'
/tmp/dummy: empty file
我是不是在滥用file? tr?我必须awk吗?我在 SunOS 5.10 上使用 bash 3.2.51,想区分 XML 和 gz 文件。
【问题讨论】: