Skip to main content
no, no carriage return, just a line feed
Source Link
Gilles 'SO- stop being evil'
  • 865.5k
  • 205
  • 1.8k
  • 2.3k

It's 32 characters! The md5sum is adding a carriage return & linefeed to the end. You can get rid of it like this:

% echo -n string | md5sum|awk '{print $1}'|wc -c
33
% echo -n $(echo -n string | md5sum|awk '{print $1}')|wc -c
32

or you could do it like this:

% echo -n $(md5sum <<< 'string'|awk '{print $1}')|wc -c
32

You can tell when one of the commands is adding a newline because the 32 character string will show up on its own line. If no newline is present it should always show up like this:

[prompt %] echo -n $(md5sum <<< 'string'|awk '{print $1}')
b80fa55b1234f1935cea559d9efbc39a[prompt %]

It's 32 characters! The md5sum is adding a carriage return & linefeed to the end. You can get rid of it like this:

% echo -n string | md5sum|awk '{print $1}'|wc -c
33
% echo -n $(echo -n string | md5sum|awk '{print $1}')|wc -c
32

or you could do it like this:

% echo -n $(md5sum <<< 'string'|awk '{print $1}')|wc -c
32

You can tell when one of the commands is adding a newline because the 32 character string will show up on its own line. If no newline is present it should always show up like this:

[prompt %] echo -n $(md5sum <<< 'string'|awk '{print $1}')
b80fa55b1234f1935cea559d9efbc39a[prompt %]

It's 32 characters! The md5sum is adding a linefeed to the end. You can get rid of it like this:

% echo -n string | md5sum|awk '{print $1}'|wc -c
33
% echo -n $(echo -n string | md5sum|awk '{print $1}')|wc -c
32

or you could do it like this:

% echo -n $(md5sum <<< 'string'|awk '{print $1}')|wc -c
32

You can tell when one of the commands is adding a newline because the 32 character string will show up on its own line. If no newline is present it should always show up like this:

[prompt %] echo -n $(md5sum <<< 'string'|awk '{print $1}')
b80fa55b1234f1935cea559d9efbc39a[prompt %]
Source Link
slm
  • 379.8k
  • 127
  • 793
  • 897

It's 32 characters! The md5sum is adding a carriage return & linefeed to the end. You can get rid of it like this:

% echo -n string | md5sum|awk '{print $1}'|wc -c
33
% echo -n $(echo -n string | md5sum|awk '{print $1}')|wc -c
32

or you could do it like this:

% echo -n $(md5sum <<< 'string'|awk '{print $1}')|wc -c
32

You can tell when one of the commands is adding a newline because the 32 character string will show up on its own line. If no newline is present it should always show up like this:

[prompt %] echo -n $(md5sum <<< 'string'|awk '{print $1}')
b80fa55b1234f1935cea559d9efbc39a[prompt %]