Rename multiple directories matching pattern

后端 未结 1 1733
一生所求
一生所求 2020-12-31 08:20

I would like to rename all directories under a basedir which match a name. For example:

In basedir/, I have:

- foo/bar/blah
- my/bar/foo         


        
1条回答
  •  伪装坚强ぢ
    2020-12-31 08:38

    find . -depth -name bar -type d -execdir mv {} baz \;
    

    -execdir changes directory to the parent before executing the command, so the mv here will be local to each parent directory.

    0 讨论(0)
提交回复
热议问题