how to store grep command in a Variable

I have a variable A

echo $A
5060

I am exporting the value X,Y,Z and it id fetching right thing and When I run

C=`${X} -l ${Y} ${Z} "trap '' INT;. ~/.profile >/dev/null 2>/dev/null; netstat -na | grep \$A`"

here it is going to same directory and also running netstat -na | grep 5060

echo $C

shows extra lines which is present in the directory with grep A value which is not actually grepped So how to avoid that value and output will come only 5060

But I need grep A value only

What's in X, and why do you have a backslash before $A? Why do you execute X inside the backticks if you don't want its output to be included? Of course, you can redirect it just like you do with the .profile (again, the purpose of which remains unclear ... do you really want that inside the backticks?)

You have the basic syntax almost right, save for the backslash. Does the following not do what you want?

C=`netstat -na | grep "$A"`

it is same as my old script but problem is that when after grep 5060 *.* is coming with grep value for that all things wgich are present in that script directory are greped in to that variable ..So I need only to avoid *.* So Pls suggest how to avoid ??

Where is the *.* (because it's not in the commands you have posted)?

How are you using $C? I'm guessing the problem might be in that context actually.

tHANKS