I have to rename some files that I don't exactly know where they are and keep their extensions.
Ex: files system-2.1.3.war, system-2.1.3.ear, system-2.1.3.ejb to system.ear, system.war,system.ejb
So I wrote this.
find /DIR1 -name "*.ear" -o -name "*.war" -o -name "*.ejb" \ -exec bash -c 'export var1={}; cp $var1 NEW_NAME${var1: -4}' \; The problem is: It works only for the last file in the "or list" of "find" command. So if the file is system-2.1.3.ejb, works, for system-2.1.3.war and system-2.1.3.ear don't.
If I change the find to
find /DIR1 -name "*.ejb" -o -name "*.war" -o -name "*.ear" Notice that *.ear now is the last one, it will work for system-2.1.3.ear and not for the others and so on.
Please help me to fix this.
I know I can create a script to accomplish that but I want a "one line" code.