sed print range alongwith line numbers.

hi working with sed in a shell script
using sed to print a range of lines from a given file
for example to print lines 12-24 from a file

sed 12,24p <filename>

however i need to print the line numbers, alongwith the actual lines
would this be possible at all?

Thanks

I suppose you mean:

sed -n 12,24p infile

You could print them in separate lines:

sed -n '2,4{=;p;}' infile

Or use awk:

awk 'NR == 12, NR == 24 { print NR, $0 }' infile