Moving files to a directory

前端 未结 6 2095
长发绾君心
长发绾君心 2020-12-16 20:13

I want to move all files matching a certain pattern in the current directory to another directory.

For example, how would I move all the files starting with

6条回答
  •  醉酒成梦
    2020-12-16 20:57

    This will do it, though if you have any directories beginning with nz it will move those too.

    for files in nz*
    do
    mv $files foobar
    done
    

    Edit: As shown above this totally over the top. However, for more complex pattern matches you might do something like:

    for files in `ls | grep [regexp]`
    do
    mv $files foobar
    done
    

提交回复
热议问题