using variable in sed

i need to use a value in the Variable to print a particular line from a file using sed command.

i tried the below one but its is not working

sed -n ' "$var"p ' abc.txt

but its is not working please help me to sort out this.

grep "$variable" myfile

You have to used double quotes instead of single quotes:

sed -n "${var}p" abc.txt

instead of

sed -n ' "$var"p ' abc.txt

Grep won't help here as i suppose you want to print out a specific line.

HTH Chris

thanks a lot chris its working :slight_smile: thanks