Copying files from different directory to common d

2019-03-04 15:39发布

I have many directories which contain .c files. I want to copy all .c files in different directories to single directory using shell script.

标签: shell
1条回答
叛逆
2楼-- · 2019-03-04 15:58
find -name '*.c' -exec cp -t /tmp {} +
  • start will all items in current directory (recursive)
  • take items with name ending .c
  • copy those items to /tmp

If you want to avoid conflicts you can add this

find -name '*.c' -exec cp --parents -t /tmp {} +

ref

查看更多
登录 后发表回答