I have searched a little bit and I found the answer in this link
but when I try to execute this command sed -i '5ianything' file1.txt
it won't work and an error message shown :
sed: 1: "file1.txt": invalid command code f
also the same error message appears when I use the other command sed -i '5i\anything' file1.txt
I don't know why it won't work for me did I miss something? is there any other way to do this?
edit
I've tried the solution provided in the comments and i run this command, but unfortunately even this won't work
sed -i.bu '5i\anything' file1.txt
sed: 1: "5i\anything": extra characters after \ at the end of i command
and this is my file1.txt :
1. alloha I want some cheese
2.
3. this is just a test and you know it
4.
5. this line will change sooooo sooooooon
6.
7. daaaamn, it changed I mean that line above me daaaaamn
edit
after I searched a little bit in man page of OSX of sed I found this :
-i extension
Edit files in-place, saving backups with the specified extension. If a zero-length extension is given, no backup will be saved. It is not recommended
to give a zero-length extension when in-place editing files, as you risk corruption or partial content in situations where disk space is exhausted, etc.