One liner renaming a group of files and directories
I have a java project with the following naming convention {project-prefix}-{project type} such that we end up with:
- files like prefix-type.xml, etc.
- directories like com/organization/pr开发者_如何学编程efix-type/.
- java files like /com/organization/prefix-type/PrefixFactory.java
I'm looking for a bash one liner that will rename the {project-prefix} portion of all of the files and directories in java project(*.java, *.xml, etc.) bonus points if it can handle the camel-case java files and/or extend the find/replace to the contents of the file
You can use the -exec
option of find
to execute a command in which you can use the name of the current matched file/directory (expanded with "{}"), something like:
find <directory> -iname <pattern> -exec mv "{}" $(modify {} whenever you want) \;
精彩评论