A script to change strings in the whole source tree. Use with care!
This commit is contained in:
parent
e4b2f5783d
commit
d57890ffa8
1 changed files with 16 additions and 0 deletions
16
scripts/change-string.sh
Executable file
16
scripts/change-string.sh
Executable file
|
|
@ -0,0 +1,16 @@
|
|||
#!/bin/bash
|
||||
# author: J. Baten
|
||||
# date: 2014-03-21
|
||||
|
||||
echo "Script to search for a string, find files containing it, and asks they can be changed"
|
||||
|
||||
read -p "Enter string to search for : " inputstring
|
||||
find . -type f \( ! -iname "*.class" \) -exec grep -H "$inputstring" {} \;
|
||||
echo "Done".
|
||||
read -p "Do you want to replace all these strings (y/n) : " answer
|
||||
if [[ ${answer,,} = 'y' ]]
|
||||
then
|
||||
read -p "Enter replacement string : " newstring
|
||||
find . -type f \( ! -iname "*.class" \) -exec grep -l "$inputstring" {} \; | xargs sed -i -e "s/${inputstring}/${newstring}/g"
|
||||
echo "Done".
|
||||
fi
|
||||
Loading…
Add table
Reference in a new issue