Skip to content

Instantly share code, notes, and snippets.

@Naheel-Azawy
Last active February 16, 2018 00:48
Show Gist options
  • Save Naheel-Azawy/607740aac3cbb0f68cb9a48c6203b0e4 to your computer and use it in GitHub Desktop.
Save Naheel-Azawy/607740aac3cbb0f68cb9a48c6203b0e4 to your computer and use it in GitHub Desktop.
Renames the app-id of a project built with GNOME Builder. Usage `rename-gnome-builder-project-app-id.sh "org.something.blabla"`
#!/bin/sh
OLD=$(grep -rh '"app-id":' *.json | sed 's/[",]//g' | awk '{print $2}')
NEW=$1
OLD2="${OLD//./\\.}"
OLD3="${OLD//.//}"
OLD4="${OLD//./\\/}"
NEW4="${NEW//./\\/}"
for s in $(find -name "*$OLD*"); do mv $s "${s/$OLD/$NEW}"; done
for s in $(grep -rIl $OLD2); do sed -i "s/$OLD2/$NEW/g" $s; done
for s in $(grep -rIl $OLD3); do sed -i "s/$OLD4/$NEW4/g" $s; done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment