There are many ways to express arithmetic things: new and old ways. However, I would like to write this line efficiently and well
sed -n '$START,$ENDp;$ENDq' < data.tex
which output
sed: 1: "$START,$ENDp;$ENDq": invalid command code S
Total Code
#!/bin/bash
function 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 $START
END=$(getEnd)
(( END++ ))
echo $END
sed -n '$START,$ENDp;$ENDq' < data.tex
where 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?
sed '/begin{document}/,/end{document}/!d;/end{document}/q' data.tex
– don_crissti Sep 11 '15 at 13:37