passing variables to sed function in a script ....

Hello ,

I have a script named testscript.sh
wherein I have two variables $var and $final (both of which contain a number)

I have a sed write function inside this script as follows:
sed '1,2 w somefile.txt' fromfile.txt

Now , in the above i want to pass $var and $final instead of hardcoding 1 and 2 .....
How do I go about???

Thanks in advance,
SD

try using double quotes ("):

sed "$var,$final w somefile.txt" fromfile.txt

thanks that worked .. :slight_smile: