printing specific line from a file.

The below line gives the perfect output when I mention the record number and file name as hardcoded.

awk 'NR==3{print}' samp2.txt

But when I pass the record num and file name as variable, it doesn't give any output.

row_num=3;file2=samp2.txt;awk 'NR==$row_num {print}' $file2

Can you please have look into it and let me know what is wrong with it?

I think you need to put ' marks around $row_num.

row_num=3;file2=samp2.txt;awk -v row="${row_num}" 'NR==row {print}' $file2
OR
row_num=3;file2=samp2.txt;awk 'NR==row {print}' row="${row_num}" $file2