将目录中所有*.txt文件合并为一个大文本文件的最快和最实用的方法是什么?
目前我正在使用cygwin的窗口,所以我可以访问BASH。
Windows shell命令也会很好,但我怀疑有没有一个。
将目录中所有*.txt文件合并为一个大文本文件的最快和最实用的方法是什么?
目前我正在使用cygwin的窗口,所以我可以访问BASH。
Windows shell命令也会很好,但我怀疑有没有一个。
当前回答
所有这些都令人讨厌....
ls | grep *.txt | while read file; do cat $file >> ./output.txt; done;
简单的东西。
其他回答
所有这些都令人讨厌....
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中
当你遇到问题,把all.txt转换成all.txt, 您可以尝试检查all.txt是否存在,如果存在,删除
是这样的:
[-e $"all.txt"] && rm $"all.txt"
这会将输出追加到all.txt
cat *.txt >> all.txt
这将覆盖all.txt
cat *.txt > all.txt
这种方法怎么样?
find . -type f -name '*.txt' -exec cat {} + >> output.txt