Same strings are not equal

Hi there can anyone help me please. I want to make a program to check if the executable file specified by the user exists in the directory.
When I run this program particulary these lines of code does not work:

if ("$fi" == "$name") then

where It checks whether the specified file is equal to the file in the directory. I thought it might be due to spaces. However, in both cases there is an additional space. So, I think they should be idetical. And question number 2: I made a brake from the loop in if statement can I do it like that???

#!/bin/csh
 if ($#argv == 1) then
        set name=$1
        set files=`ls`
        set  numfiles=`echo $files | wc -w`
       @ count=1
        while ( $count < $numfiles)
        set fi=`echo $files | cut -f$count -d ' '`
        if (-f $fi && -x $fi ) then
                        set charnum=`echo $fi | wc -c`
                        if ("$fi" == "$name") then
                                echo "I am here 3"
                                echo $fi
                                break
                        endif
        endif
        @ count = $count + 1
        end
endif

Thanks in advance! :slight_smile:

Looks like you are not making friends with your csh problems/questions. Neither could I answer, as my csh days are gone for long.

In bash, however, I would phrase your command like so:

if [ "$fi" == "$name" ]; then ...

i.e. square brackets with spaces around and a terminating ";". Please be careful not to intermingle your "fi" variable with the fi reserved word to end an if- statement.