Bash: Copy named files recursively, preserving folder structure

后端 未结 6 769
借酒劲吻你
借酒劲吻你 2020-11-29 17:48

I was hoping:

cp -R src/prog.js images/icon.jpg /tmp/package

would yield a symmetrical structure in the destination dir:

/t         


        
6条回答
  •  天命终不由人
    2020-11-29 18:39

    Have you tried using the --parents option? I don't know if OS X supports that, but that works on Linux.

    cp --parents src/prog.js images/icon.jpg /tmp/package
    

    If that doesn't work on OS X, try

    rsync -R src/prog.js images/icon.jpg /tmp/package
    

    as aif suggested.

提交回复
热议问题