Linux - GeneralThis Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Hello, does anyone know how to make sed get the md5 checksum hash from a file.
I have some files that have random md5 checksum hash on it content, trying to figure out how i can set sed to know the md5 hash between all the lines and words in the files.
md5 is a 32 character string of a random hexadecimal numbers [0-9][a-f].
i tried to set identifier in sed to show the hash after it, but it also show the worlds in the same line after the hash.
any idea ?
Last edited by Dr_Death_UAE; 05-15-2008 at 06:50 AM.
You will have to show what you have so far, or a sample line before someone can provide much help.
You probably want to use the form:
sed '/<md5pattern>/s/.*\(<md5pattern>\).*/\1/' file
to select the line with the md5sum and to only output the match.
thanks colucix, awk work fine, is there a way to get the hash without any identifier, i mean if the "md5sum=" is a variable and the hash also a variable. not all of the files have "md5sum=".
Please note that you have to specify the --posix option of awk to let it recognize the braced interval expression {32} in the regular expression, which is disabled by default.
Hmmm... once I read about the FreeBSD version of awk not supporting extended regular expressions and in particular the interval expression I used in the command above. I don't know much about FreeBSD, but as alternative you can try something like
Code:
grep -E -o '[0-9a-f]{32}' file
I'm not sure if grep on FreeBSD supports the -o option, to print the matching part only.
Yes. A lot of differences, in the sense that the GNU awk (gawk) has introduced new advanced features not available in standard unix's awk. Portability of your awk code is an issue when you are used to the GNU extension of awk.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.