diff --git a/wolf_scripts/sed_rename.sh b/wolf_scripts/sed_rename.sh new file mode 100755 index 0000000000000000000000000000000000000000..53d20f2bba1f57a7c4569d1dd27b8d5ec09974ea --- /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