From 18be81a5701260ee41778b45580bc6c34f8a3ec4 Mon Sep 17 00:00:00 2001 From: jcasals <jcasals@iri.upc.edu> Date: Mon, 18 May 2020 11:04:44 +0200 Subject: [PATCH] Add renaming script --- wolf_scripts/sed_rename.sh | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100755 wolf_scripts/sed_rename.sh diff --git a/wolf_scripts/sed_rename.sh b/wolf_scripts/sed_rename.sh new file mode 100755 index 000000000..53d20f2bb --- /dev/null +++ b/wolf_scripts/sed_rename.sh @@ -0,0 +1,28 @@ +#!/bin/bash +#$1 flag telling whether we are in test mode or not + +modify=$1 +apply=false + +if [[ "$modify" = true || "$modify" = t ]]; then + read -p "Are you sure? " -n 1 -r + echo # (optional) move to a new line + if [[ $REPLY =~ ^[Yy]$ ]] + then + apply=true + echo "Modifying..." + fi +fi + +string="StringToBeReplaced" +replace="ReplacementString" + +for file in $(find include/ src/ test/ demos/ -type f); do + if [ "$apply" = true ]; then + # echo "APPLYING" + sed -Ei 's%'$string'%'$replace'%g' $file + else + # echo "NOT APPLYING" + sed -En 's%'$string'%'$replace'%gp' $file + fi +done -- GitLab