This question is super fun and very beautiful. In my work we had to rename several "* .py" files for a testing environment and we tried in every way to suit everyone. I preferred to try to use shell scripting and I used most of the recommended in the answers, I even used xargs and several command substitutions several times, another partner gave up and did a script in python but in the end the answer was too simple and beautiful.
Use rename
.
In your case you can use this:
$ rename 's/.cpp/.cc/' *
I think the syntax is self-explanatory, otherwise, rename receives a pattern indicating the replacement of what contains .cpp with .cc in the complete file expansion (by the glob) in the folder.
It's nice because the rename
program was created by Larry Wall, the creator of Perl, and fun because everyone makes you think too much for something "simple".
Another way you can do it, if you like something a little more complicated, is:
$ find . -maxdepth 1 -mindepth 1 -name "*.cpp" | xargs -I {} bash -c 'echo {} $(echo {} | sed "s/cpp/cc/g")' | xargs -I {} bash -c "mv {}"
The result is the same.