我在Windows中找到了一种做这种事情的方法
echo "This is just a sample line appended to create a big file. " > dummy.txt
for /L %i in (1,1,21) do type dummy.txt >> dummy.txt
http://www.windows-commandline.com/how-to-create-large-dummy-file/
在UNIX中,有没有一种方法可以复制文件,追加然后重复该过程?像for .. cat file1.txt > file1.txt
什么?
yes "Some text" | head -n 100000 > large-file
用csh
/ tcsh
:
repeat 10000 echo some test > large-file
与zsh
:
{repeat 10000 echo some test} > large-file
在GNU系统上,另请参见:
seq 100000 > large-file
或者:
truncate -s 10T large-file
(创建10TiB稀疏文件(非常大,但不会占用磁盘上的任何空间)),以及在“创建具有大量零字节的测试文件”中讨论的其他替代方法。
这样做cat file >> file
将是一个坏主意。
首先,它不适用于某些cat
拒绝读取与其输出文件相同的文件的实现。但是,即使您通过执行来解决此问题cat file | cat >> file
,如果file
它大于cat
内部缓冲区,那也将导致cat
无限循环运行,因为最终将读取其早先写入的数据。
在由旋转硬盘驱动器支持的文件系统上,它的效率也相当低(在达到比可能缓存在内存中更大的大小之后),因为驱动器需要在读取数据的位置之间来回移动,以及在哪里写。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句