regex - Extract stuff between the first pipes in bash? -
i want extract stuff in between first 2 pipes:
| a650f360-a29d-4562-b46f-024fe15aa7dc | emi-ubuntu-12.04.2-server-amd64-08152013 | active |
the output should be:
a650f360-a29d-4562-b46f-024fe15aa7dc
i have regex going use sed with: ^\|\s*(.*?)\s*\|
but according regex calculator gets me pipes well. how rid of it?
sed 's/^[^|]*|\([^|]*\)|.*/\1/'
that matches non-pipes @ beginning (nothing in example data), pipe, captures stuff isn't pipe, matches pipe , @ end, , replaces captured stuff.
Comments
Post a Comment