I have a file "testfile" with 10 lines. I want to print lines 3 (lower) to 6(upper) out of these lines. So I use cat testfile | sed -n 3,6p to print the lines. Now if I calculate the upper limit to be displayed based on some calculation and the result is saved in a variable say "y". Assume y=6, how can I use the same sed command now??
sed -n 3,$yp doesn't work as yp is considered like a variable here. How do I distinguish between $y and p here.