I want to replace the input,
find_string: @include circle-progress(38px, 30px, #4eb630)
and output,
Output_string: @include circle-progress(38px, 30px)
using ${find_string//pattern/replacement_string} where pattern is , , #[A-Fa-f0-9][A-Fa-f0-9][A-Fa-f0-9]?([A-Fa-f0-9]?([A-Fa-f0-9]?([A-Fa-f0-9])))' that I supply.
In the code below, simply the line matching pattern is printed i.e find_string, when I read lines of code from a file, whereas I want the output_string to be printed.
pattern="@include circle-progress\(([0-9]{1,3}px, ){2}#[A-Fa-f0-9]
{3,6}\)" /*regex the matches find_string*/
replace_glob=', #[A-Fa-f0-9][A-Fa-f0-9][A-Fa-f0-9]?([A-Fa-f0-9]?([A-
Fa-f0-9]?([A-Fa-f0-9])))' /*glob pattern in the string to be replaced*/
while IFS='' read -r line || [[ -n "$line" ]]; do
if [[ $line =~ $pattern ]]
then
echo "${line//$replace_glob/}"
fi
done < "$1"
#4eb630from the input string right?${source/orig/repl/}, the variablesorigandreplcannot be vaiables, they can just be strings. You need to usesedfor replacementecho "${source//$replace_glob/}"with just a singlesourcein interactive mode. It replaces @include circle-progress(38px, 30px, #4eb630) with @include circle-progress(38px, 30px).awkorsed; this is the type of task they were created to handle.