Here is my code aiming to diff .in and .out file in batches. Both .in and .out files are in same directory and sorted by name. So, two files needed to test should be adjacent in directory. But when I want to use outFile=${arr[$(i++)]} to get the .out file, it shows i++: command not found. What's the error in my script?
#!/bin/sh
dir=$PATH
arr=($dir/*)
for((i=0;i<${#arr[@]};i++));do
inFile=${arr[$i]}
outFile=${arr[$(i++)]}
if diff $inFile $outFile > /dev/null; then
echo Same
else
echo $inFile
fi
done
PATHis (nearly always) not a single directory, but a colon-separated list of directories.