nested for loops

I need help getting over this bump on how nested for loops work in shell. Say i was comparing files in a directory in any other language my for loop would look like so

for(int i=0;to then end; i++)
for(int y = i+1; to the end; y++)

I can't seem to understand how i can translate that into shell,
where I want the first for loop to start at the first file and the second for loop to start at the second.

so

for f in $aDirectory; do
  for f in $aDiredtory

confuses me. Since f in both loops would start at the same file. Any recommendations?

Not sure what you plan to do with it.
But you may find this useful to get started:

y=""
for f in $aDirectory; do
   if [ y != "" ]; then
       echo "newfile = $f and oldfile = $y"
   fi;
   y=$f
done

In the below line you have used 2 diff. variables "i" and "y".

for(int i=0;to then end; i++)
for(int y = i+1; to the end; y++)

But in the actual "for" loop you are using same variable "f" for both.

for f in $aDirectory; do
  for f in $aDiredtory
for (( i=0; i<=x; i++ ))
do
  for (( y=0; y<=z; y++ ))
  do

Reference: ABC on "C-style for loops" (see example 10-12, lower part)

repost

i guess my question is how would i do that with nested for-do loops in shell when iterating through a directory start at two different indexes?

for aFile in aDirectory;do
    for theNextFile in aDirectory; do
         cmp aFile theNextfile

when i run the 'real' code it returns the same file since both for loops start at the same point. How would i offset the second for loop so it starts out on the next file?

Your approach is correct.
The top loop will get one file at a time.
The inner loop, will compare the above first file with all the files in the directory.
The only hitch is, in the inner loop, when comparing, every file will be comparing to itself once. You can take care of this by comparing the file name in an if-else condition.

Lets say you have files A, B, C, D
What you will get is:

 
Loop1     Loop2     Loop3     Loop4
-----     -----     -----     -----
*A=A       B=A       C=A       D=A
A=B      *B=B       C=B       D=B
A=C       B=C      *C=C       D=C
A=D       B=D       C=D      *D=D

A=A then if-else condition to ignore?.