At work, we're generating a "next generation" set of tools. We wanted to create a new name to help differentiate the new tools from the old tools, but we also wanted to start with the same code base as the old tools. To accomplish this, we needed to change all references to the old name into the new name. To do this, I used the following commands:
This one finds the actual files and directories with the "Old" names and changes them:
The short explanation of this command is that it finds all files with Old in the filename, then determines what the filename would be replacing Old with New, and then moves the file. This may have to be run several times, since the parent directories may be renamed before the child directories are reached.
Then we had to replace all references to the Old tool name in the actual files:
This just finds all files in your directory, and uses sed to do an "in place" substitution of Old with New.
Hope this is helpful to somebody!
This one finds the actual files and directories with the "Old" names and changes them:
for f in `find | grep Old`; do export A=`echo $f | sed 's:Old:New:g'`; mv $f $A; done;
The short explanation of this command is that it finds all files with Old in the filename, then determines what the filename would be replacing Old with New, and then moves the file. This may have to be run several times, since the parent directories may be renamed before the child directories are reached.
Then we had to replace all references to the Old tool name in the actual files:
find -exec sed -i "s:Old:New:g" {} \;
This just finds all files in your directory, and uses sed to do an "in place" substitution of Old with New.
Hope this is helpful to somebody!
No comments:
Post a Comment