Thanks to: @Diego Torres Milano
https://stackoverflow.com/a/48569466/175063
#!/bin/bash
find /home -type f -name "wp-config.php" -print0 | while read -rd $'\x00' f
do
cat '[%s]\n' "$f" | grep DB_NAME
done
But, seems to be missing something:
#!/bin/bash
find /home -type f -name "wp-config.php" -print0 | while read -rd $'\x00' f
do
cat '[%s]\n' "$f" | grep DB_NAME | cut -d \' -f 4
done
With the results of:
./test.sh: line 5: unexpected EOF while looking for matching ``'
./test.sh: line 8: syntax error: unexpected end of file
Ultimately, I want something along the lines of:
#!/bin/bash
find /home -type f -name "wp-config.php" -print0 | while read -rd $'\x00' f
do
printf '%s\n' "$f"
WPDBNAME=`cat '%s\n' "$f" | grep DB_NAME | cut -d \' -f 4
WPDBUSER=`cat '%s\n' "$f" | grep DB_USER | cut -d \' -f 4
WPDBPASS=`cat '%s\n' "$f" | grep DB_PASSWORD | cut -d \' -f 4
echo $WPDBNAME
echo $WPDBUSER
echo $WPDBPASS
done
Thanks!