Issue
I am trying to match the below pattern which has spaces in between.
-DsomeArg=some value
and to replace it with below pattern using sed command.
-DsomeArg="some value"
There can be any number of spaces in between. I tried below command but it's not working.
sed 's/^\(-D.*\)=(.\+\s\+.\+)/\1="\2"/' test.dat
where as .* works instead of .+ , but I want to match one or more pattern. I am not able to find what I am doing wrong.
Solution
cat /tmp/test | sed -r 's/^(-D.*?)=(.+\s+.+)/\1="\2"/'
-DsomeArg="some value"
Hope that will help :)
Answered By - Adam Sznajder