bash - Using variables in sed -n x,yp to print lines from line number x to line number y -


i have file "testfile" 10 lines. want print lines 3 (lower) 6(upper) out of these lines. use cat testfile | sed -n 3,6p print lines. if calculate upper limit displayed based on calculation , result saved in variable "y". assume y=6, how can use same sed command now??

sed -n 3,$yp doesn't work yp considered variable here. how distinguish between $y , p here.

with curly braces:

sed -n 3,${y}p file 

and useless use of cat can avoided, too. :)


Comments

Popular posts from this blog

java - pagination of xlsx file to XSSFworkbook using apache POI -

Unlimited choices in BASH case statement -

apache - How do I stop my index.php being run twice for every user -