I would like to insert lines into a file in bash starting from a specific line.
Each line is a string which is an element of an array
line[0]=\"foo\"
sed is your friend:
:~$ cat text.txt foo bar baz ~$ ~$ sed '/^bar/\na this is the new line/' text.txt > new_text.txt ~$ cat new_text.txt foo bar this is the new line baz ~$