I'm trying to replicate the behavior of the sha1sum executable in some java code, however, in the process I've discovered that sha1sum appears to behave differently given the same input in two scenarios.
Assume input of '12345' without the single quotes and with no newline.
If I put this data into a file (file1) and run sha1sum from the command line:
$ sha1sum file1 8cb2237d0679ca88db6464eac60da96345513964 file1
However, if I do this, I get a different result:
$ cat file1 | grep -vi foo | grep -vi bar | sha1sum 2672275fe0c456fb671e4f417fb2f9892c7573ba -
Using the apache commons-codec jar, I'm able to read in file1, get it's contents, and perform a .shahex() on the content and get the first result. However, I need to get the second result (due to legacy code) and I can't figure out why sha1sum is behaving differently, or what grep is doing to the input.
The system is running CentOS 5.4 with sha1sum 5.97