I need some help with sed regex substitution.
From the following line:
Provides mysql
I want to get:
Provides mysql-5.5
The best solution I was able to come with is:
sed -i "s/\(Provides\)\(\s\)*\(mysql\)/\1\2mysql-5.5/g" my_file_containing_the_line
but the result is not as I want:
Provides mysql-5.5
Which is not perfect because I lost the white spaces between “Provides” and “mysql-5.5”
Thanks
\2group does not contain all spaces"s/\(Provides\)\(\s*\)\(mysql\)/\1\2mysql-5.5/g"will work.Beside that you can use
--regexp-extendedoption to suppress redundant escaping:Or even