I would like to replace variations of a string using sed. The string pattern is required to match a set of optional repeatable characters ("../") and a mandatory string ("foo") For e.g. ../foo ../../foo ../../../foo
I can replace a single version such as ../../../foo using pattern which will yield using sed:
sed - 's/\.\.\/\.\.\/\.\.\/foo/foo1/'
=> foo1 but I want to extend to match any version so I get: ../foo => foo1 ../../foo => foo1 ../../../foo => foo1
How do I achieve this using sed?