Skip to content

Instantly share code, notes, and snippets.

@huyphamwork
Created November 17, 2017 03:35
Show Gist options
  • Save huyphamwork/2d01bb7263684c0bbca7ab8a11f4fb22 to your computer and use it in GitHub Desktop.
Save huyphamwork/2d01bb7263684c0bbca7ab8a11f4fb22 to your computer and use it in GitHub Desktop.
#!/bin/bash
# Find and change text in file with "sed"
# https://unix.stackexchange.com/questions/159367/using-sed-to-find-and-replace
# http://www.thegeekstuff.com/2009/09/unix-sed-tutorial-replace-text-inside-a-file-using-substitute-command/?utm_source=sitekickr&utm_medium=snip_button
DIRS=`ls -l "." | egrep '^d' | awk '{print $9}'`
for DIR in $DIRS
do
FILE=$DIR"/wp-config.php"
sed -i -e "s/define('DB_PASSWORD',.*);/define('DB_PASSWORD', 'root');/g" $FILE
sed -i -e "s/define('DB_USER',.*);/define('DB_USER', 'root');/g" $FILE
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment