i need diff understanding :)

Can someone tell me where i'm going wrong

if [ "$file1" \< "$file2" ]; then                 
     set outPut = diff "$file1" "$file2" | wc -l
     echo $file1 $file2;
     echo "$outPut"
        if [$outPut == 0];then
                echo " "$file1" and "$file2" " v
         fi
fi

This is the following result:

line 52 is referring to the "if [$output = 0]; then"
and line 40 refers "if [ ! -f $file2 ]; then" which is not listed.

It's missing spaces after [, before ]


if [ "$file1" \< "$file2" ]; then                 
     set outPut = diff "$file1" "$file2" | wc -l
     echo $file1 $file2;
     echo "$outPut"
        if [ $outPut == 0 ];then
                echo "$file1 and $file2" v
         fi
fi

I don't really know what \< means!

i've checked all the white spaces but I still can't see where else the problem is this what i have now

                if [ ! -f $file1 ]; then
                   continue
                   fi
                for file2 in *
                  do
                  if [ ! -f $file2 ]; then
                     continue
                     fi

		#//checks if file1 is being compared to another different file; not itself
                if [ "$file1" \< "$file2" ]; then 
                     set outPut = `diff "$file1" "$file2" | wc -l`
                     if [ $outPut == 0 ]; then
                         echo " "$file1" and "$file2" " # // prints file if same content
                     fi
                fi

Again the error message is

62: refers to if [ $outPut == 0 ]; then
50. refers to if [ ! -f $file1 ]; then
55. refers to if [ ! -f $file2 ]; then

White spaces again?

I've never heard of the '\<' operator before (line 60 by your reckoning). Could you explain that one?

For line 62 it might be that one of the files does not exist, or that one of the variables $file1 or $file2 are not declared (I can't see where $file1 is declared in your script).

Use

outPut = $(diff $file1 $file2 2>/dev/null | wc -l)
if [ $outPut == 0 ]; then
...

or better

diff $file1 $file2 > /dev/null 2>&1
if [ $? -eq 0 ]; then
...

And it pointless to say

for file2 in *
do
 if [ ! -f $file2 ]; then
   continue
 fi
...

because if * expands nothing the for-loop is not executed, so you can assume that file2 does exist.

And use "set -n" in your script (ksh - or the equivalent for your shell) to check the syntax without running it to see where the errors are.

(oh, and what is the \< all about?)

Umm, I have never heard of '<' operator for test command, test being synonym for '['. If you (according to your comment in the code) want to check that you are not comparing a file against itself, use -ef operator of test.

Furthermore, there is no such operator as '==' - if you want to compare numbers, use -eq, for strings the comparison operator is '='.

Regards,

pen