I have a number of md5 files that were either generated on windows machines or transfered in binary mode (bit for bit). As a result the end-of-line characters are formated with CRLF.
Code:
cat -e windows.md5
d4c638e28b1990c55b79e5249cf33038 *testfile_01.ext^M$
9e15845bdae8c1d1699dade90b73c744 *testfile_02.ext
When I translate them with
Code:
tr -d '\r' <windows.md5> linux.md5
the CR is removed
Code:
cat -e linux.md5
d4c638e28b1990c55b79e5249cf33038 *testfile_01.ext$
9e15845bdae8c1d1699dade90b73c744 *testfile_02.ext
and I can use
Code:
md5sum -c linux.md5
with success except for the last file/line to be checked.
My problem is that the last line in the file never had any end-of-line characters to begin with.
As a result, md5sum -c linux.md5 returns an error for the last line.
Code:
md5sum -c linux.md5
testfile_01.ext: OK
md5sum: testfile_02.ext : No such file or directory
testfile_02.ext : FAILED open or read
md5sum: WARNING: 1 of 2 listed files could not be read
If I open the linux.md5 file with EMACS, delete the last "blank" characters of the file then hit return, then save that I find the last line is fixed
Code:
9e15845bdae8c1d1699dade90b73c744 *testfile_02.ext$
and will be used by md5sum correctly.
I would like to be able to script the fix and not have to manually go through every md5 file by hand. It seems like an easy problem but it has got me vexed...
I have tried appending to the file:
Code:
cat >> linux.md5
Blah
^D
but that only returns
Code:
d4c638e28b1990c55b79e5249cf33038 *testfile_01.ext$
9e15845bdae8c1d1699dade90b73c744 *testfile_02.ext $
Blah$
Please notice the space between the "testfile_02.ext" and "$".
This returns the same error.
If I could only insert the correct end-of-line character for the last line I think I would be fixed.
Any suggestions?