I am using sed to find a pattern in a line and then I want to retain the pattern + the rest of the line. How is this possible? ie:
line is: 14158 05-15-08 20:00 123-1234-A21/deliverable/dhm.a
search for 123-1234-A21 ie:
echo $line | sed 's/.*\([0-9]\{3\}-[0-9]\{4\}-[0-9A-Z]\{3\}[A-Z]\{5\}\).*/\1/'
want to retain 123-1234-A21/deliverable/dam.a
Is using sed the best option for this? currently it only retains the 123-1234-A21
Thanks!