I have file "setting.xml" which contains some environment variable
<localRepository>/Users/$(whoami)/.m2/repository
I want to write the content of setting.xml into production.xml and replace the $(whomai) with my userid
I tried below
cat setting.xml | echo > production.xml
but not sure how can I pass the content to my echo command
You can try:
sed "s/\$(whoami)/$(whoami)/" < setting.xml >production.xml
The sed
is an stream editor, and in the above, replaces the literal $(whoami)
with the result of the command whoami
.