简体   繁体   English

如何删除具有路径模式的所有文件

[英]how to delete all files with a path pattern

I have a backup location, which uses hardlinks to store existing or changed files. 我有一个备份位置,它使用硬链接来存储现有或已更改的文件。 The location of these backups mimick the linux file system with a date part in it. 这些备份的位置模仿linux文件系统,其中包含日期部分。

For example I have files 例如,我有文件

/backup/servername/2012-06-26T00.43.01/www.website.com/file1.html
/backup/servername/2012-06-26T06.43.01/www.website.com/file1.html
/backup/servername/2012-06-26T06.43.01/www.website.com/file2.html
/backup/servername/2012-06-26T12.43.01/www.website.com/file1.html
/backup/servername/2012-06-26T12.43.01/www.website.com/file2.html

How can I find all files which have www.website.com in them, so I can delete them 如何查找其中包含www.website.com的所有文件,以便删除它们

I have this command combination to delete files I can find with find, but I can't figure out how to find these files. 我有这个命令组合来删除我用find找到的文件,但我无法弄清楚如何找到这些文件。

find . -name 'filename.*' -print0 | xargs -0 rm

You're being a little loose with your terminology, so it's a kind of tough to understand what exactly you want. 你的术语有点松散,所以你很难理解你想要什么。 However, if I understood you correctly, you want to delete all the files within a directory called www.website.com : 不过,如果我理解正确的话,你要删除一个名为目录中的所有文件www.website.com

find . -wholename '*/www.website.com/*.html' -delete

if i understood you right you can use smth like this: find /backup/servername/2012-06-26T12.43.01/www.website.com/ -iname '*file*' -print0 | xargs -0 rm 如果我理解你,你可以像这样使用smth: find /backup/servername/2012-06-26T12.43.01/www.website.com/ -iname '*file*' -print0 | xargs -0 rm find /backup/servername/2012-06-26T12.43.01/www.website.com/ -iname '*file*' -print0 | xargs -0 rm

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM