I exaktly typed it like this and it does not work, instead it deletes the last line from the existing file:
sed -e '$a\
line5' test.txt
---------- Post updated 05-07-12 at 08:29 AM ---------- Previous update was 04-07-12 at 10:05 PM ----------
Finally I figured out what the problem was.
The file I used was edited by windows and so the last line did not had
an UNIX End of Line (LF) instead an Windows End of LIne (CR+LF).
So SED was not able to detect the end of file.
Whenever you want to add an Line to the end of file using SED, this Script should be right:
sed -e '$a\
NEW Line' file.txt
If somebody got the problem and is transferring data via Windows watch out that line ends within UNIX-Standard, that is LF and not CR+LF.
---------- Post updated 06-07-12 at 03:55 AM ---------- Previous update was 05-07-12 at 08:29 AM ----------