I've never really used the write command much, but I'm working on a script where I want to insert a line into a file. It seems pretty straightforward but the text always gets put in the last line of the file.
At first I made the line dynamic.
var %li_ = $lines(file.txt) - 1
write $+(-i,%li_) file.txt Testing
This should write the line "Testing" to the second to last line in the file, but it always puts it in the last line.
I;ve tried a static line number.
/write -i5 file.txt Testing
This writes to the last line as well...
Whats going on? What am I missing?