delete the last line of a file
sed '$d' < nxip > nxip2 ; mv nxip2 nxip

delete of the line containing the string "-"
sed '/-/d' < nxip > nxip2 ; mv nxip2 nxip

delete from specific line (26) to end of file
sed -i '26,$d' /etc/hosts

insert specific line
sed -i '25r nxip' /etc/hosts

More: awk and sed - แทรกไฟล์ไปยังบรรทัดที่ต้องการ (Loop and Variables)