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

android - net_scheduler holding wakelock -

sql - MySQL : Getting Entries from a many-to-many table -

java - Retrieving data from database using jsp (Hibernate + Spring + Maven) -