The following command works as expected and changes the username to abc
sed -e 's/username=company_user/username=abc/' Service.properties
But if the username is something different other than 'company_user' it will fail for obvi开发者_运维问答ous reasons. How do I use wildcards here?
It depends on what is a valid username, but here's a start:
sed 's/username=[a-z0-9_]+/username=abc/i' Service.properties
This will replace any username consisting of upper or lower case letters (note the i
at the end, which makes the pattern case-insensitive), numbers and/or underscores with "abc". If you need to add other characters, just add them within the []
.
精彩评论