Issue
This is what I do currently:
pass1=$(grep DB_PASSWORD /home/user/public_html/wp-config.php | cut -d ' ' -f3)
# it echoes 'password' with start and end single quotes
pass=${pass1:1:-1}
# it remove single quotes from start and end
But I want to combine these two commands in a single go.
I tried some wrong commands which showed me the help of grep
.
Solution
You could use awk
:
pass=$(awk -F"'" '/DB_PASSWORD/{print $4}' /home/user/public_html/wp-config.php)
I simply defined '
to be the field separator, which makes the password the 4th field.
Answered By - tink Answer Checked By - Timothy Miller (WPSolving Admin)