Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It's 100% free, no registration required.

I am using the following bash script to update an email address "[email protected]" but the problem I have is that the field could be anything, not necessary "[email protected]" 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, '[email protected]', 'admin@$(hostname)');"

mysql --user=root --password=PASSWORD DATABASE << eof
$updatevar
eof
share|improve this question
    
This is a DB/query question, this might be posted in dba.stackexchange.com –  tachomi May 28 at 17:16

1 Answer 1

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)';"
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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