I'd like to extract hash values with sed
from strings like this one:
[129.173.213.225:52196] some_text: another_text --> eb1d94daa7e0344597e756a1fb6e7054
The desired result is just have the 32-byte hash value, eb1d94daa7e0344597e756a1fb6e7054 in this example.
So I tried the following command with regexp
(idea is to remove all except the matched pattern):
% sed 's/\([0-9a-f]{32}\)$/\1/g' < file
which results in error:
sed: -e expression #1, char 20: invalid reference \1 on `s' command's RHS
Passing -r
to sed didn't help, I'm getting the same error.
I think the regexp itself is correct because sed -r 's/[0-9a-f]{32}$/XXX/g'
does replace the 32-byte hash value with XXX string. But I want to remove all of the string except the hash value.
% cat /etc/issue
Ubuntu 16.04.6 LTS \n \l
%
% ls -la `which sed`
-rwxr-xr-x 1 root root 73424 Feb 11 2016 /bin/sed
%
What am I doing wrong?