Parameterized ed command

Hi!, i have a problem when i trying to replace, in this script, the number five with a variable.

ed file <<< $'1,5d\nw'

i need something like that

ed file <<< $'1,${VAR}d\nw'

I believe that ' can not be replaced with " in this sentence, because i tried it and throws "?" (an error occurs)

Thanks,
Juan.

This should work:

ed file <<%
1,${VAR}d
w
%

or use sed which is better suited for such tasks.

thank you so much!, it works very well :wink:

I'm using ed instead of sed because i want to edit a file in situ without creating a temporary file.