I have elasticsearch.yml file.
I need to update path.data and path.logs value based on user input.
I wrote .sh script to take path as argument and replace string but it replaces with empty value.
Under script am using this
sed -i.bak -e 's/# path.data:.*/ path.data: $2 /' "$1"
sed -i.bak -e 's/# path.logs:.*/ path.logs: $3 /' "$1"
Example : ./updateconfig.sh /usr/local/elasticsearch/config/elasticsearch.yml /var/lib/elasticsearch /var/log/elasticsearch
I tried with double quotes (") too but no luck.
Can you please help me on this.
Update
Adding example and error when trying with different options
Example :
sed -i.bak -e "s/# path.data:.*/ path.data: $2 /" "$1"
sed -i.bak -e 's># path.data:.*> path.data: $2 >' "$1"
sed -i.bak -e "'s># path.data:.*> path.data: $2 >'" "$1"
Errors:
sed: -e expression #1, char 32: unknown option to
s' sed: -e expression #1, char 1: unknown command:
''