【发布时间】:2014-10-09 16:36:32
【问题描述】:
prepend to a file one liner shell? 解决问题的一个方法是:
cat header main | tee main > /dev/null
正如一些 cmets 所注意到的,这不适用于大文件。
这是一个有效的例子:
$ echo '1' > h
$ echo '2' > t
$ cat h t | tee t > /dev/null
$ cat t
1
2
以及它在哪里中断:
$ head -1000 /dev/urandom > h
$ head -1000 /dev/urandom > t
$ cat h t | tee t > /dev/null
^C
命令挂起,杀死它后我们剩下:
$ wc -l t
7470174 t
是什么导致上述命令卡住并无限添加行的行为? 1 行文件场景有什么不同?
【问题讨论】: