Rename multiple files based on pattern in Unix

前端 未结 22 1197
死守一世寂寞
死守一世寂寞 2020-11-22 06:31

There are multiple files in a directory that begin with prefix fgh, for example:

fghfilea
fghfileb
fghfilec

I want to rename a

22条回答
  •  借酒劲吻你
    2020-11-22 06:53

    There are several ways, but using rename will probably be the easiest.

    Using one version of rename:

    rename 's/^fgh/jkl/' fgh*
    

    Using another version of rename (same as Judy2K's answer):

    rename fgh jkl fgh*
    

    You should check your platform's man page to see which of the above applies.

提交回复
热议问题