2
0

sources_replace.sh 674 B

12345678910111213141516171819202122232425262728293031
  1. #!/bin/bash
  2. from=$1
  3. to=$2
  4. if [[ $from == '' ]]; then
  5. echo "replace from must not be empty"
  6. exit 1
  7. fi
  8. if [[ $to == '' ]]; then
  9. echo "replace to must not be empty"
  10. exit 1
  11. fi
  12. if [[ ! -d src || ! -d ide ]]; then
  13. echo "please execute the script under trunk"
  14. exit 1
  15. fi
  16. echo "from=$from"
  17. echo "to=$to"
  18. files="configure `ls auto` `ls conf` `ls scripts` `find etc -type f` `find ide -type f|grep -v xcuserdata` `find research -type f|grep -v objs` `find src -type f`"
  19. for file in $files; do
  20. grep -in "$from" $file >/dev/null 2>&1;
  21. if [[ 0 -eq $? ]]; then
  22. echo "replace $file";
  23. sed -i '' "s|$from|$to|g" $file;
  24. fi;
  25. done