$ cat file | tr -d 'xyz'
-
runs two processes, one for cat and one for tr. This is less
-
efficient than
-
两个进程
-
$ tr -d 'xyz' < file
-
in general, "cat file | somecommand" can
be more efficiently
-
replaced by "somecommand < file" or (especially for multi-file
input)
-
$ somecommand file [file ...]
-
cat file1 file2
- 只有多个文件的时候cat的效率才比<高
本文探讨了如何利用tr命令直接在文件中替换特定字符,相较于使用cat和管道的方式,此方法在多文件操作时更为高效。通过对比示例,详细解释了tr命令的使用场景和优势。
205

被折叠的 条评论
为什么被折叠?



