1

The command sha256sum correctly calculates checksum indicated in .sha256 file:

user@myHostname:~/Desktop/RT_N16/Merlin_JohnsFork$ sha256sum RT-N16_3.0.0.4_374.43_2-39L3j9527.trx
545927719c46e359a0db6bf9dcb348f99c0f3d8786725780cb182994c61b19be  RT-N16_3.0.0.4_374.43_2-39L3j9527.trx

All files are in the same directory. I did NOT create the Contents of a .sha256 file:

user@myHostname:~/Desktop/RT_N16/Merlin_JohnsFork$ cat sha256sum.sha256 
545927719c46e359a0db6bf9dcb348f99c0f3d8786725780cb182994c61b19be  RT-N16_3.0.0.4_374.43_2-39L3j9527.trx

The sha256sum command reads the .sha256 file and returns an error:

user@myHostname:~/Desktop/RT_N16/Merlin_JohnsFork$ sha256sum -c sha256sum.sha256
sha256sum: 'RT-N16_3.0.0.4_374.43_2-39L3j9527.trx'$'\r': No such file or directory
: FAILED open or read_2-39L3j9527.trx
sha256sum: WARNING: 1 listed file could not be read

QUESTIONS

  • Is the above syntax incorrect or is there a problem with the .sha256 file?

  • Is the command trying to open a filename= _2-39L3j9527.trx?

gatorback
  • 5,785
  • 9
  • 40
  • 65
  • It seems the file name inside sha256sum.sha256 isn't present from where you're trying to sha256sum check. Either "RT-N16_3.0.0.4_374.43_2-39L3j9527.trx" should be present inside the same directory as sha256sum.sha256 or have its path specified in sha256sum.sha256 like 545927719c46e359a0db6bf9dcb348f99c0f3d8786725780cb182994c61b19be /home/user/RT-N16_3.0.0.4_374.43_2-39L3j9527.trx – Abhishek Nair Aug 03 '19 at 05:20
  • 1
    How did you create sha256sum.sha256? It seems there is a formatting problem 'RT-N16_3.0.0.4_374.43_2-39L3j9527.trx'$'\r': vs. RT-N16_3.0.0.4_374.43_2-39L3j9527.trx. Try to edit or recreate the file with an editor on your Ubuntu system. – Thomas Aug 03 '19 at 08:39
  • 1
    The file appears to have Windows (CRLF) line endings - see How to change Windows line-ending to Unix version – steeldriver Aug 03 '19 at 12:35
  • @steeldriver If you care to add a formal answer, you will earn due credit. The dos2unix command corrected the .sha256 file for UNIX – gatorback Aug 03 '19 at 14:17

1 Answers1

1

If you look carefully, you can see that the message is actually

filename$'\r': No such file or directory

The $'\r' is the shell's way of telling you that there is a carriage return (\r) character at the end of the string. This indicates that the sha256sum.sha256 file has DOS- or Windows-style line endings (CRLF) in place of the Unix standard LF endings.

You can fix the file using one of the methods described in How to change Windows line-ending to Unix version

You can use the program dos2unix, which is specifically designed for this:

dos2unix file.txt

will replace all CR from all lines, in place operation.

To save the output in a different file:

dos2unix -n file.txt output.txt

You might need to install it first by:

sudo apt-get install dos2unix
gatorback
  • 5,785
  • 9
  • 40
  • 65
steeldriver
  • 136,215
  • 21
  • 243
  • 336