How do I limit the results of the command find in bash?

后端 未结 2 823
悲&欢浪女
悲&欢浪女 2021-01-07 22:51

The following command:

find . -name \"file2015-0*\" -exec mv {} .. \\;

Affects about 1500 results. One by one they move a previous level.

2条回答
  •  粉色の甜心
    2021-01-07 23:53

    You can do this:

     find . -name "file2015-0*" | head -400 | xargs -I filename mv  filename ..
    

    If you want to simulate what it does use echo:

     find . -name "file2015-0*" | head -400 | xargs -I filename echo mv  filename ..
    

提交回复
热议问题