簡體   English   中英

如何在任何匹配的子文件夾組中找到所有文件並將它們復制到新目錄?

[英]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 \; 

為此使用-pathipath選項。 這兩個選項再次匹配給定的 glob 模式路徑名:

find . -ipath "*/snapshots/failures/*" -type f -exec cp {} ~/desktop \;

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM