I'm reposting this question with more context and examples because admittedly my last post was rushed. I'm trying to find ALL MD5 hashes (based off the regex) and simply lowercase them (regardless of format, and regardless of what else is on the line).
I previously posted a similar question related to lowercasing emails and this was the solved answer (maybe this can assist in finding the answer).
sed -e 's/^\([^@]*\)@/\L\1@/' file
The MD5 Regex I use is: [a-f0-9]{32}
I'll provide some examples now (each line is unique - there's NOT a set pattern)
Input data:
fwefwe:few32rfwe:3r2frewg:-::d3ewStack:D077F244DEF8A70E5EA758BD8352FCD8
fwefwe:few33rfwe:3r2frewg:-::dsasaewStack:06D80EB0C50B49A509B49F2424E8C805
fwefwe:few34rfwe:3r2f3213ef::2d3ewStack:F1BDF5ED1D7AD7EDE4E3809BD35644B0
fwefwe:few35rf32re4frewgre3frewg:-::d3ewStack:DDE2C7AD63AD86D6A18DE781205D194F
Output data:
fwefwe:few32rfwe:3r2frewg:-::d3ewStack:d077f244def8a70e5ea758bd8352fcd8
fwefwe:few33rfwe:3r2frewg:-::dsasaewStack:06d80eb0c50b49a509b49f2424e8c805
fwefwe:few34rfwe:3r2f3213ef::2d3ewStack:f1bdf5ed1d7ad7ede4e3809bd35644b0
fwefwe:few35rf32re4frewgre3frewg:-::d3ewStack:dde2c7ad63ad86d6a18de781205d194f
You may use
sed -E 's/[A-F0-9]{32}/\L&/g' file
If you also want to modify the existing file add -i
option:
sed -i -E 's/[A-F0-9]{32}/\L&/g' file
The point is that you need to use an -E
option to enable POSIX ERE regex syntax and write {...}
quantifier without escaping. POSIX BRE equivalent will look like sed -i 's/[A-F0-9]\{32\}/\L&/g' file
.
Also, I added g
flag to modify all match occurrences on a line.