I wrote a shell script that used SED to make context-specific changes along with copying files (among other things). Out of the six scripts only one of them consistently experienced a problem – the last line was missing in all of the copies.
I wondered if there was some kind of dependency between the steps where something wasn’t getting properly written out, but that seemed odd for Unix. I tried to do line by line comparisons to find the error in my shell scripts. Finally, I came up with a different solution – simply add an additional blank line to the file to be copied. After that, everything worked fine.
It wasn’t until I was studying SED in more detail yesterday that I realized that this was a necessary step. SED seemed to ignore transforming or working with the last line of input that did not end with a newline. I find this odd – if the last line of a file does not end with a newline, SED will ignore it? There has to be more to the story than that.
Anyway, I am about halfway through my study with SED and will blog on that and then move on to AWK.