Command not found errors when running csh script

I am trying to find the number of files whose name starts with uni.
Below is the code but it is giving error. :confused:

#!/bin/csh
FILES_NAME ='files_list';
FILE_NAME_PATTERN = 'uni*';
NO_OF_FILES;
ls -l $FILE_NAME_PATTERN > $FILES_NAME ;
NO_OF_FILES = `wc -l $FILES_NAME`;
echo $NO_OF_FILES;

When run give the following warnings.

$ ./unix_4.sh
FILES_NAME: Permission denied.
FILE_NAME_PATTERN: Command not found.
NO_OF_FILES: Command not found.
FILE_NAME_PATTERN: Undefined variable.
$

But when the following commands are issued

ls -l uni* > files_list and
wc -l files_list 

runs perfectly.

What is the problem :confused::confused:

You should have NO space before and after the sign =

in csh , you should use

set var=value

for example:

set FILES_NAME='files_list'

and remove the line:

NO_OF_FILES;
1 Like

For the same query as above
Let say I want to get the absolute path of all the file found using ls

How to do that ??

Not sure about what you are willing to get ... maybe something like :

find $PWD -type f -prune

?