Now this is ingenious! We just need to tell sed to change the delimiter to get the above to work:
When using sed for substitution, the character following the 's' is automatically taken as the delimiter. For patterns the non-default delimiter needs to be introduced with a backslash:
Code:
ls | sed -nr "\:^$prefix([0-9]{4}$|[0-9]{6}$):p"
Thank you for your time, sycamorex.