Undefined variable error in csh script

Below csh script gives error: Undefined variable:confused:

 
#!/bin/csh
$QUERY="netscape";
COUNT_NETSCAPE=${ps | grep -c $QUERY};
echo $COUNT_NETSCAPE;

when run gives error

adroit:/home/seo/hitendra 64 ] ./unix_6.sh
QUERY: Undefined variable.

What is the root cause of the above problem ?

Remove $ from second line.

QUERY="netscape";

On removing $ it again gives error as below

adori:/home/seo/hitendra 70 ] ./unix_6.sh
QUERY=netscape: Command not found.
Variable syntax.
#!/bin/csh
set QUERY='netscape'
set COUNT_NETSCAPE=`ps | grep -c $QUERY`
echo $COUNT_NETSCAPE
1 Like