I'm working on a bash script that will split the contents of a text document depending on the data in the line.If the contents of the original file were along the lines of01 line01 line02 line02 lineHow can I insert into line 3 of this file using bash to result in01 line01 linetext to insert02 line02 lineI'm hoping to do this using a heredoc or something similar in my script#!/bin/bashvim -e -s ./file.txt <<- HEREDOC    :3 | startinsert | text to insert\n    :update    :quitHEREDOCThe above doesn't work of course but any recommendations that I could implement into this bash script?
Insert text at specific line number
shell script;text processing
You can use Vim in Ex mode:ex -sc '3i|text to insert' -cx file.txt3 select line 3i insert text and newlinex write if changes have been made (they have) and exit