These are a few commands I use in situation where I can’t use Eclipse for refactoring my code, you can use them by replacing from
and to
with the names you want.
No need to remind you to take backups to prevent irreversible loss of data.
Rename files and folders
me@linux:~/$ find . ! -path . -name '*' -exec bash -c 'echo $0 ${0/from/to}' {} \;
Rename variables
me@linux:~/$ find . -type f -print | xargs sed -i 's/from/to/g'
Rename variables in bulk
me@linux:~/$ find . -type f -print | xargs sed -i 's/from/to/g;s/foo/bar/g;s/FOO/BAR/g'
Maybe using sublime text can be a good refactoring tool instant of Eclipse.
Yes, you can get away with your IDE search/replace, PHPStorm/Rubymine/Webstorm and like have a great refactoring tool… Yet, nothing beats the speed and dangerousness of the command line.