4

I have a library of files. Each file has each own *.md5 file (created by Total Commander) with md5 hash and additional *.txt file with some comments.

Is there any way to move these comments from *.txt file to *.md5 file (and delete *.txt file) in a form of some internal block of comments (like using "rem" in Windows batch files or "<! --" and "-- >" in HTML) so I could still use *.md5 files to check the hashes?

Lex
  • 444
  • 1
  • 3
  • 12

2 Answers2

3

Use # as a comment character.

The accepted answers suggesting ; works with Total Commander in Windows, but gives an error with GNU's md5sum, and probably also with other tools:

md5sum: WARNING: 1 line is improperly formatted

But both Total Commander and the standard md5sum accept the usual Unix comment character # instead. So use that.


Additional notes:

While Windows has traditionally been using ; as a comment character, particularly in it's older .ini files, Unix mostly uses # in it's shells and most scripting environments. (and Windows too now, in Powershell).

Since (arguably) most uses of md5 are on Unix machines where tools like md5 on Macs or md5sum on Linux come with the OS, the traditional # seems a bit safer.

Note also that TC on Windows accepts .md5 files with Unix "LF" line endings (or "/" as path separator), but the Unix tools cannot check md5 files using Windows "CRLF" line endings (or "\" in paths).

However, there is nothing about comments in the original RFC 1321, and there doesn't seem to be any official mention of using comments in .md5 files...

mivk
  • 13,452
  • 5
  • 76
  • 69
  • Hmmm... very interesting! I was using `;` all the time with TC since that previous answer and it always worked but I've never tried to use it with any other tool. What's the reason of such problem with other tools? Is `;` the official md5 comment character but some tools didn't implement it? Or is it used only by TC and the official md5 comment character is `#`? – Lex Feb 27 '22 at 14:05
  • @Lex : my answer ended up being too long for a comment, so I added it to the answer itself... – mivk Feb 27 '22 at 16:52
  • Thank you! So `;` is not some md5's feature but it comes from Windows? – Lex Feb 27 '22 at 17:19
0

Any line beginning with ; in .md5 files is a comment.

Danny
  • 528
  • 1
  • 4
  • 27
  • Ah, this is the answer I was looking for - thank you so much! I suppose ";" will work till the end of line and another ";" in that line will not stop my comment? – Lex Aug 05 '20 at 16:21
  • Right, it will work to the end of line no matter what the line contains. – Danny Aug 06 '20 at 17:08