A sed difference between Linux and OS X
In Linux, I can change the contents of a file from the command line with a simple sed one-liner: sed -i ‘s/^”//’ *.txt
What this does is delete any quotation marks that are at the very beginning of a line in all text files in that folder. With the -i flag, it makes the changes directly to the existing file, without needing to specify a new file name. This gives you the option to rename the current file and write the changes to a new file with the same name, but by default on many Linux distributions, if you don’t explicitly specify that you want to do that, it just commits the changes directly to the existing file. Otherwise you could add in a “.bak” and the original file would be backed up in case the change was done improperly.
In OSX, however, the system requires you to specify a new file name. If you don’t want to create a backup of the original file, you can leave the name blank, but you still have to add it in like such: sed -i “” ‘s/^”//’ *.txt
Notice after the sed -i there is a double quotation with nothing between them. If I put in sed -i “.bak” ‘s/^”//’ *.txt, the original file would be named “whatever.txt.bak”. If I leave it blank such as “”, the original file would be overwritten with the changes from the sed utility.
It’s a small difference, but it’s easy to forget that OS X and Linux are not the same system. So much is so similar. These small differences can become jarring, especially to someone who holds three Linux certifications. What do you mean my script doesn’t work?! I tested it on Ubuntu!