I have users like below in many *sh scripts.


I want to replace any emails like above with admin@yahoo.com in linux.

Any idea will be appreciated ?

| improve this question | | | | |

To replace the part before @ (I think that's what you want), you could use:

sed 's/[^ ]\+@/admin@/g' file
  • s/old/new/ replace old with new
  • [^ ]\+@ match at least one non-whitespace character followed by @
  • g do the replacement on all matches, even if it occurs more than once on the line.
| improve this answer | | | | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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