LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 06-28-2017, 02:24 AM   #1
andrew6166
LQ Newbie
 
Registered: Jun 2017
Posts: 2

Rep: Reputation: Disabled
MD5sum - Ignoring WHitespace


I would like to do an MD5 checksum on a directory in linux. Problem is that the checksum says that whitespace is makes the check fail. How can I ignore white space when doing a md5sum check.


I generate chksum file like so

find /tmp/ -type f -name * -exec md5sum {} >> tmp.chksum \;


then check other side on different server

md5sum -c tmp.chksum

There is a space which is being counted as difference.

How can I do this. Should I use another tool
 
Old 06-28-2017, 03:20 AM   #2
pan64
LQ Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 16,636

Rep: Reputation: 5614Reputation: 5614Reputation: 5614Reputation: 5614Reputation: 5614Reputation: 5614Reputation: 5614Reputation: 5614Reputation: 5614Reputation: 5614Reputation: 5614
where is this space located exactly?
 
Old 06-28-2017, 03:32 AM   #3
andrew6166
LQ Newbie
 
Registered: Jun 2017
Posts: 2

Original Poster
Rep: Reputation: Disabled
MD5SUM ignoring whitespaces

The original file would be

(test.file)
hello

THe file im testing against will be
(test.file)
hello
#new line here
 
Old 06-28-2017, 03:48 AM   #4
pan64
LQ Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 16,636

Rep: Reputation: 5614Reputation: 5614Reputation: 5614Reputation: 5614Reputation: 5614Reputation: 5614Reputation: 5614Reputation: 5614Reputation: 5614Reputation: 5614Reputation: 5614
so the files are not identical, but one of them contains an additional new line. You need to remove it before calculating md5sum. I can't see other ways, but probably someone has an idea.
you can use sed/awk/perl/python or something else to remove that char. Using perl or python you may also try to read the file, cut the last char and calculate md5sum "in one".
 
Old 06-28-2017, 04:33 AM   #5
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 19,787

Rep: Reputation: 3574Reputation: 3574Reputation: 3574Reputation: 3574Reputation: 3574Reputation: 3574Reputation: 3574Reputation: 3574Reputation: 3574Reputation: 3574Reputation: 3574
Huh ?.
They are different - why do you expect them to resolve to the same ?. Doesn't make any sense. Nor does "munging" the file before md5 - ask an auditor what s?he thinks about that. Whoa.
 
Old 06-28-2017, 07:56 AM   #6
rtmistler
Moderator
 
Registered: Mar 2011
Location: USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu, Debian
Posts: 9,356
Blog Entries: 13

Rep: Reputation: 4411Reputation: 4411Reputation: 4411Reputation: 4411Reputation: 4411Reputation: 4411Reputation: 4411Reputation: 4411Reputation: 4411Reputation: 4411Reputation: 4411
Hi andrew6166 and welcome to LQ.

As others are saying, there is no way to ask an MD5 checksum to ignore whitespace, newlines (which is not whitespace by the way), or other characters.

The long winded solution would be to download the MD5Sum source and write your custom form of it.

I do not recommend doing a special, one-of solution for this.

Please realize that the whole point of the MD5 checksum is to guarantee that both files are absolutely identical in all respects.

You may wish to consider diff(1), please check out the -b and -w options, as well as explore the wide variety of available options for that command.
 
1 members found this post helpful.
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] MD5Sum - How do I compute the MD5Sum of a downloaded iso? kd6tzf Linux - Newbie 13 01-29-2015 12:15 PM
whitespace in path m_pahlevanzadeh Linux - General 2 06-05-2010 12:57 PM
ls with whitespace in filenames jhwilliams Linux - Software 6 07-01-2007 03:34 AM
whitespace in fstab senyahnoj Linux - General 5 02-26-2007 07:31 AM
ignoring the "non-portable whitespace encountered at line " warning Jake13 Linux - Software 3 08-18-2004 12:34 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 01:31 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration