Missing trailing new line when using cat in a bash script
Recently, I was writing a bash script that read a file into a string and then passed that string elsewhere that then calculated the hash of it. To my surprise, I was getting a different hash to doing the equivalent in PHP with file_get_contents(). Digging into it, I discovered that when you assign the output of cat to a variable, the trailing new line in the file is stripped off, which explained the difference. You… continue reading.