These are my folders/files:
backup/
├── folder1
│   ├── file1.txt
│   ├── file2.txt
│   └── file3.txt
└── folder2
file1.txt (is empty) file2.txt (there is only X inside the file) file3 (last created empty)
My Script:
#!/bin/sh
#config-checker.sh
#First loop looks at each folder in backup/. 
for j in `ls backup/  -1t` 
do
    #change directory to other folders
    cd backup/${j}/
    N=0
    #Grab the two newest files. Add them to an array called FILE
    for i in `ls -1t | head -2`
    do
        FILE[$N]=$i
        N=$N+1
    done
    #diff the two files in FILE
    var=`diff ${FILE[0]} ${FILE[1]}`
    #if a diff exists, show it
    if [[ ${var} ]]
        then
        #script here takes two variables; the name of the folder and the content of the diff
        echo $j "${var}"
    fi
done
It's not getting me the diff on the file, my output is this:
./config-checker.sh: 17: FILE[0]=file2: not found ./config-checker.sh: 17: FILE[0+1]=file3: not found ./config-checker.sh: 1: Bad substitution folder1 ./config-checker.sh: 11: cd: can't cd to backup/folder2 ./config-checker.sh: 17: FILE[0]=file2: not found ./config-checker.sh: 17: FILE[0+1]=file3: not found ./config-checker.sh: 1: Bad substitution folder2
Not sure what Im missing here. Any help would be appreciated. Thank you
 
    