I'm currently writing a script to mass reset wordpress username and passwords. The passwords were stored using old-passwords and now with an update to MySQL and PHP, the old passwords are no longer working and hence need to be reset.
I have a file that looks like this:
define('DB_USER', 'abc_12345');
define('DB_PASSWORD', 'abc12345');
define('DB_USER', 'def_34589');
define('DB_PASSWORD', 'def34589');
I'm just needing to return the values inside the single quotes:
DB_USER abc_12345
DB_PASSWORD abc12345
DB_USER def_34589
DB_PASSWORD def34589
Now, I've looked around at the similar questions, but they all are a bit different then what I'm working with.
I've tried the following:
cat file.txt | awk '{print $1,$2}'
which returns
define('DB_USER', 'abc_12345');
define('DB_PASSWORD', 'abc12345');
define('DB_USER', 'def_34589');
define('DB_PASSWORD', 'def34589');
I've tried
cat file.txt | awk '{print $1}'
which returns
define('DB_USER',
define('DB_PASSWORD',
I've tried
cat file.txt | awk '{print $2}'
which returns
'abc_12345');
'abc12345');
I've also tried awk mixed with grep
cat file.txt | awk '{print $2}' | grep -P " '*.' "
which doesn't return anything.
awk -F\' '{print $2,$4}' file.txt
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With