I'm going over this topic in unix and i'd be glad if someone could explain this bit of script: sed 's/\(abc\)*/xyz/' so the input would be abcabcabc which results in xyz Also how come 'xyz' doesnt repeat 3 times because the input is 'abc' x 3 ?

Thanks in advance,


sed 's/string1/string2/' replaces string1 with string2. the 's' signifies the substitution.

you are grouping the letters 'abc' i.e. (abc) using \(abc\) using the \ to escape the literal interpretation of the parenthesis.

The asterisk is used to signify one or more occurences of the group 'abc'.

It is the reason you are getting a single 'xyz' as the output.

type the same without the asterisk to see the change in output.

Hope it helps!

Yes definitely it all makes sense now,

Thanks alot ! :)