How to move or copy files listed by 'find' command in unix?

后端 未结 5 1799
一向
一向 2020-11-30 23:28

I have a list of certain files that I see using the command below, but how can I copy those files listed into another folder, say ~/test?

find . -mtime 1 -ex         


        
5条回答
  •  感动是毒
    2020-12-01 00:15

    If you're using GNU find,

    find . -mtime 1 -exec cp -t ~/test/ {} +
    

    This works as well as piping the output into xargs while avoiding the pitfalls of doing so (it handles embedded spaces and newlines without having to use find ... -print0 | xargs -0 ...).

提交回复
热议问题