Issue
I want to use sed command to replace sensitive information in logs with ****
.
One of the log looks like:
"Log: abcservice : dataUsername generated is = [email protected]\n","stream":"stdout""
The expected output I want is:
"Log: abcservice : dataUsername generated is = ******@as.bbi.co\n","stream":"stdout""
I tried:
sed 's#"dataUsername generated is [[email protected]]"#"dataUsername generated is = ******"#g"
How can I match the pattern "dataUsername generated is = [email protected]" and replace it with "dataUsername generated is = ******@as.bbi.co\n"
Solution
Using sed
$ sed -E 's/(dataUsername generated is = )[^@]*/\1******/' input_file
"Log: abcservice : dataUsername generated is = ******@as.bbi.co\n","stream":"stdout""
Answered By - sseLtaH Answer Checked By - Senaida (WPSolving Volunteer)