I have file with
File
foo
bar
I want to insert a line with text like this
text="some long text $100"
position="2"
I want to run
sed "$position a $text"
the result should be
foo
bar
some long text $100
The File isn’t 3 lines long this is just shortcode. Other tools can be used like awk
>Solution :
text='some long text $100'
position=2
sed "$position"'a\
'"$text
" file