Look at these two files:
They look to me entirely identical, but File 1 has 41 bytes and File 2 has 44 bytes.
Now, I would not care about 3 extra chars, however, I think these chars are also responsible to a strange error: when I clone and run these files, File 1 runs OK while File 2 returns an error on line 3: "./BasicCheck.sh: line 3: cd: case0 : No such file or directory".
So: what are these extra chars? Why do they cause errors? And what should I do to fix these errors?
My guess is that they are newlines - perhaps File 1 has Linux-based newlines and File 2 has Windows-based newlines. Is it correct? And why should it cause such errors?
od -c filename
and you'll be shown the exact characters in the files. If one script has DOS-style newlines (with a 3 line file, that would account for the extra 3 bytes) then I would have expected a different error message. Or specifically, the same error message, but "garbled". – glenn jackman Mar 19 '19 at 15:21$filename\r
with an extra invisible character. But I'd expect the error message to start with: No such file or directory
because of the carriage return in the middle of the error message. – glenn jackman Mar 19 '19 at 15:23dos2unix
command is your friend to fix such files. You should investigate the settings for your editor to save files in "unix format". – glenn jackman Mar 19 '19 at 15:42