I'm using the following command to get the year out of a string using sed.
echo 1234-1-12 | sed -r 's/(\d{4})-\d{1,2}-\d{1,2}/\1/'
but somehow it returns the entire date instead of the year.
getting 1234-1-12
expecting 1234
Any ideas why it doesn't work?