如何连接具有相同preFIX(很多prefixes)文件? [英] How to concatenate files with the same prefix (and many prefixes)?
问题描述
我有相同preFIX许多文件,只下划线后的位是不同的。而且我有很多prefixes的!
下划线没有其他地方出现在文件名。我怎么可以连接都具有相同的preFIX的文件到一个新的?
我补充说,我有成千上万不同的prefixes的,我不能养活他们的循环。
I have many files that have the same prefix, only the bit after the underscore is different. And I have many prefixes as well! Underscore does not appear anywhere else in the file name. How can I concatenate all the files with the same prefix into a new one? I am adding that I have thousands of different prefixes and I cannot feed them to the loop.
推荐答案
您可以这样做:
cat /path/prefix* >> new_file
它将猫
(即串联文件和打印到标准输出
)的名字匹配的所有文件 /路径/ preFIX
。文本的其余部分是可以是不同的。
It will cat
(that is, concatenate files and print on the standard output
) all files whose name matches /path/prefix
. The rest of the text is what can be different.
执行,这是好做之前 LS /路径/ preFIX *
,以确保它得到所有(且仅这些)文件要考虑到考虑。
Before executing that it is good to do ls /path/prefix*
to make sure it gets all (and only these) files you want to take into consideration.
$ ls
aa_bb prefix_23 prefix_235 prefix_nnn
$ ls prefix_*
prefix_23 prefix_235 prefix_nnn
这篇关于如何连接具有相同preFIX(很多prefixes)文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!