How to copy every file with extension X while keeping the original folder structure? (Unix-like systems)

前端 未结 2 1371
迷失自我
迷失自我 2021-01-26 00:56

I am trying to copy every HTML file from an src folder to a dist folder. However, I should like to preserve the original folder structure and if the dist folder does not exist I

2条回答
  •  感动是毒
    2021-01-26 01:35

    find _src -type f -name "*.html" -exec cp -t _dist --parents {}  ";"
    
    • cp -t : target directory
    • --parents : append parents dir to target

    This will omit empty (no html-files) dirs. But if you need them, repeat without -name "*.html" but with -type d.

提交回复
热议问题