Skip to content

Instantly share code, notes, and snippets.

@spiashko
Created October 1, 2020 23:57
Show Gist options
  • Save spiashko/cc8d3a05ceda5b9e5c4d8c10e2b44578 to your computer and use it in GitHub Desktop.
Save spiashko/cc8d3a05ceda5b9e5c4d8c10e2b44578 to your computer and use it in GitHub Desktop.
#!/bin/sh
ENTITY_NAME=$1
NEW_ENTITY_NAME=$2
find . -name "$ENTITY_NAME*.java" \
-exec rename -n 's,'"$ENTITY_NAME"'(.*).java,'"$NEW_ENTITY_NAME"'$1.java,i' {} \;
read -p "Are you sure? " -n 1 -r
echo # (optional) move to a new line
if [[ $REPLY =~ ^[Yy]$ ]]
then
find . -name "$ENTITY_NAME*.java" \
-exec rename 's,'"$ENTITY_NAME"'(.*).java,'"$NEW_ENTITY_NAME"'$1.java,i' {} \;
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment