简体   繁体   中英

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.

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

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 . -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 :

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 find /backup/servername/2012-06-26T12.43.01/www.website.com/ -iname '*file*' -print0 | xargs -0 rm

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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