将目录中所有*.txt文件合并为一个大文本文件的最快和最实用的方法是什么?
目前我正在使用cygwin的窗口,所以我可以访问BASH。
Windows shell命令也会很好,但我怀疑有没有一个。
将目录中所有*.txt文件合并为一个大文本文件的最快和最实用的方法是什么?
目前我正在使用cygwin的窗口,所以我可以访问BASH。
Windows shell命令也会很好,但我怀疑有没有一个。
当前回答
所有这些都令人讨厌....
ls | grep *.txt | while read file; do cat $file >> ./output.txt; done;
简单的东西。
其他回答
type [source folder]\*.[File extension] > [destination folder]\[file name].[File extension]
例如:
type C:\*.txt > C:\1\all.txt
这将采取所有的txt文件在C:\文件夹,并将其保存在C:\1文件夹的名称为all.txt
Or
type [source folder]\* > [destination folder]\[file name].[File extension]
例如:
type C:\* > C:\1\all.txt
这将获取文件夹中所有文件,并将Content放在C:\1\all.txt中
您可以使用Windows shell拷贝来连接文件。
C:\> copy *.txt outputfile
来自帮助:
若要追加文件,请为目标指定一个文件,但为源指定多个文件(使用通配符或file1+file2+file3格式)。
你可以这样做: 猫(directory_path) / * * / *。[h,m] > test.txt
如果使用{}包含要查找的文件的扩展名,则存在顺序问题。
这种方法怎么样?
find . -type f -name '*.txt' -exec cat {} + >> output.txt
所有这些都令人讨厌....
ls | grep *.txt | while read file; do cat $file >> ./output.txt; done;
简单的东西。