There are many ways to express arithmetic things: new and old ways. However, I would like to write this line efficiently and wellsed -n '$START,$ENDp;$ENDq' < data.texwhich outputsed: 1: $START,$ENDp;$ENDq: invalid command code STotal Code#!/bin/bashfunction getStart {        local START=$(awk '/begin\{document\}/{ print NR; exit }' data.tex)        echo $START}function getEnd {        local END=$(awk '/end\{document\}/{ print NR; exit }' data.tex)        echo $END}START=$(getStart)(( START-- ))echo $STARTEND=$(getEnd)(( END++ ))echo $ENDsed -n '$START,$ENDp;$ENDq' < data.texwhere the SED is getting the linenumbers from local variables of functions.How can you express the first line by expressing the variables efficiently for the SED?
How to express variables efficiently for SED?
bash;sed
Variables aren't expanded in single quotes. Use double quotes:sed -n $START,${END}p;${END}q < data.texAlso, since you want the value of END followed by the character p, and not the value of ENDp, you need to indicate where the name of the variable ends. You can use the ${END} syntax, which makes it explicit where the variable name ends.Note that if $START or $END are not numbers but regular expressions, you might need to escape some characters.