execute command stored in a string

Hi,

Here's the problem I am facing.
This is just an example:

 
list_files.ksh
------------
dir=$1
match=$2
 
var="ls $dir | grep $match"
files=`"$var"`

I get the below error on executing the above script:

./list_files.ksh[5]: ls /home/my_files | grep xml: not found

I know I am doing something very silly. Can you please tell me?

-dips

files=`eval "$var"`

Hi bartus11,

Thanks it worked!

-dips