I am using the following bash script to update an email address "currentemail@email.com" but the problem I have is that the field could be anything, not necessary "currentemail@email.com" I have tried to use '*' instead, how can I run the following to work for whatever the current email is set as under "emailaddress" field?

#! bin/bash
updatevar="UPDATE email_users SET emailaddress = REPLACE(emailaddress, 'currentemail@email.com', 'admin@$(hostname)');"

mysql --user=root --password=PASSWORD DATABASE << eof

closed as unclear what you're asking by roaima, GAD3R, phk, Rui F Ribeiro, Anthony Geoghegan May 27 '17 at 16:25

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.


If I understand the question well, you want to replace all email addresses on the database, right? In that case, use the following:

updatevar="UPDATE email_users SET emailaddress = 'admin@$(hostname)';"
  • This would set the email address of all users. We don't have enough information about the schema or data to determine how to update the correct row in the email_users table. – Kusalananda May 27 '17 at 11:32

Not the answer you're looking for? Browse other questions tagged or ask your own question.