mv command with awk

Guillaume Zussy
Guillaume Zussy used Ask the Experts™
on
Hello experts !

I have several files which are referred to as GCE* (e.g GCE_ihm_parametrage.props). I want to rename all of them in order to skip GCE_.
e.g : GCE_env_param --> env_param

I already thought about a solution that uses awk :

find . -name GCE_* | awk -F"_" ... but i'm lost after the awk...

Can you help me ?

Thanks in advance !
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Most Valuable Expert 2013
Top Expert 2013
Commented:
Hi,
you can try this -
find . -type f -name GCE_\* | while read fn ; do echo mv $fn  $(echo $fn | awk -F"GCE_" '{print $1 $2}'); done
Note 1) I put echo in front of mv for you to test. Remove it when you're satisfied with the results.
Note 2) Please make sure that the part of the filename following GCE_ is unique, else mv will overwrite the output file[s]!
wmp
Guillaume ZussyJava middleware Admin

Author

Commented:
Thank you wmp ! It's really great !

I tested it and it worked perfectly !

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial