My file data Pattern is below and i need output as 6 or 3 or 8 or 4 based on the variable value which is eth0 and eth1
eth0RX:6:eth0TX:3|eth1RX:8:eth1TX:4|
Below code works well
sed 's/.*eth0RX:\([0-9]\+\).*/\1/g' $EMSTATE/packetdrop.txt
But fails when I use dynamic variable like below
rxfile=sed 's/.*$iRX:\([0-9]\+\).*/\1/g' $EMSTATE/packetdrop.txt