only print a selected row

this works:

cat file.txt| awk 'NR==45,NR==55'

but how do I assign variables instead of numbers:
this does not work:

cat file.txt | awk 'NR==$start,NR==$end'  

there need variables instead of numbers

Sorry for my English
Thank you for answer

awk -v start=$whatever -v end=$wherever 'NR==start,NR==end' file.txt

or

sed -n "$start,$end p" file.txt

--ahamed

1 Like

No need to use cat:

awk -v s=$start -v e=$end 'NR==s,NR==e' file
1 Like

thank you,
One more thing printed by lines will be shown up, do not know how?