![](/img/trans.png)
[英]How to find all files in a directory and subdirectories that contain using partial names within a list then copy them to a new folder
[英]How can I find all files in any matching sub folder groups and copy them to a new directory?
我有一個由多個子項目構成的項目。 作為該項目的一部分,我有一些在快照 UI 測試失敗時生成的失敗差異。
當前已添加到原始快照旁邊的文件夾中。
我希望能夠運行測試套件並將任何故障快照復制到一個位置——這將在 CI 期間發生,並使我能夠將它們存儲為工件。
結構類似於;
Project/
Framework A/
snapshots/
failures/
failure_a_img_1.png
failure_a_img_2.png
Framework B/
snapshots/
failures/
failure_b_img_1.png
failure_b_img_2.png
failure_b_img_3.png
.........
Framework Z/
snapshots/
failures/
failure_z_img_1.png
failure_z_img_2.png
我基本上希望能夠搜索整個Project
文件夾並復制文件夾組中匹配snapshots/failures
的任何文件
如果我在終端中運行echo **/*snapshots/failures/*
我會看到所有文件/位置。 我嘗試使用構建命令
find . -iname "**/*snapshots/failures/*.png" -type f -exec cp {} ~/desktop \;
但沒有 output / 沒有復制任何內容。
我會很感激這方面的任何幫助。
您應該傳遞目錄 glob 以find
並將文件名傳遞給-iname
。
find **/*snapshots/failures -iname "*.png" -type f -exec cp {} ~/desktop \;
為此使用-path
或ipath
選項。 這兩個選項再次匹配給定的 glob 模式路徑名:
find . -ipath "*/snapshots/failures/*" -type f -exec cp {} ~/desktop \;
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.