[英]how can I print the name of all files from a folder
I have like 10000 files in a folder and I want to know which one is doublicated. 我在一个文件夹中有10000个文件,我想知道哪个文件是重复的。 I like to save only the names of them in a txt file
我只想将它们的名称保存在txt文件中
Is there any way to do it? 有什么办法吗?
My files look like this. 我的文件如下所示。 as an example
举个例子
..._P2_A1-(01)_....tx
For me it is doublicated when I have the first part twice QEX2_P2_A1
对我来说,当第一部分获得两次
QEX2_P2_A1
I did try to print it but with no success for example, here is one solution Bash: How to print the filename of the nth file in a folder or Extract filename and extension in Bash which did not work for me. 我确实尝试打印它,但是没有成功,例如,这是Bash的一种解决方案:如何在文件夹中打印第n个文件的文件 名或在Bash中提取文件名和扩展名,这对我不起作用。 I have tried to search it but I could not find any solution
我尝试搜索它,但找不到任何解决方案
You can use printf + awk
to print all partially duplicated filenames: 您可以使用
printf + awk
打印所有部分重复的文件名:
printf "%s\n" *.txt | awk -F '_' '{k=$1 FS $2 FS $3} k in seen{dups[seen[k]]=k; dups[$0]=k}
{seen[k]=$0} END{for (f in dups) print dups[f] " => " f}'
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.