This is short for "Useless use of cat". It's used to point out
that
some example script has used cat when it could have used
redirection
instead. It's more efficient to redirect input than
it is to spawn a
process to run cat. For example
UUOC是"Useless use of
cat"的缩写。如果脚本中使用cat命令的代码可以用"重定向"代替,你就可以称其为UUOC。因为重定向的效率要比运行一个外部命令要高。比如:
$ cat file | tr -d 'xyz'
runs two processes, one for cat and
one for tr. This is less
efficient than
同时运行了两个进程 cat 和
tr,这种用法的效率比下面这句要低
$ tr -d 'xyz' < file
In
general, "cat file | somecommand" can be more efficiently
replaced by
"somecommand < file"
or (especially for multi-file input)
but check the man page for "somecommand" to find out if it
will
accept this syntax.
For more details about this, as
well as other things like it, see 如果你愿意也可以这么写 cat file | somecommand somecommand < file < file somecommand #bash适用,其他shell不知道 第三种是否和cat的习惯有点接近?都是把要操作的文件放在前面。