문제

I have a property file mail.properties. The content of the file is

ErrorEmailTo.server1=abc_1@gmail.com,bcd_1@gmail.com,efg_1@gmail.com 
ErrorEmailFrom.server1=abc_1@gmail.com,bcd_1@gmail.com,efg_1@gmail.com
ErrorEmailCC.server1=abc_1@gmail.com,efg_1@gmail.com,bcd_1@gmail.com

...and numerous such entries.

I want to find bcd_1@gmail.com and delete it wherever it is present. The output property file (mail.properties) should look like :

ErrorEmailTo.server1=abc_1@gmail.com,efg_1@gmail.com 
ErrorEmailFrom.server1=abc_1@gmail.com,efg_1@gmail.com
ErrorEmailCC.server1=abc_1@gmail.com,efg_1@gmail.com
도움이 되었습니까?

해결책

You can try this sed,

sed 's/bcd_1@gmail.com,\?//g; s/,*$//' mail.properties

Use -i option for in-place edit.

sed -i 's/bcd_1@gmail.com,\?//g; s/,*$//' mail.properties

다른 팁

sed -e 's/bcd_1@gmail\.com//g' -e 's/,,/,/g' -e 's/,$//g' -e 's/=,/=/g' mail.properties > mail.properties_new
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top