Skip to main content
3 of 3
fixed a few quoting issues
Stéphane Chazelas
  • 585.1k
  • 96
  • 1.1k
  • 1.7k

Try this:

find /Class/ -maxdepth 1 -mindepth 1 -type d | while IFS= read -r student; do
    find "$student" -type f -newer "$student/Unit/MarkSheet"*
done

The first find looks for the student directories and the second for files neer than the corresponding MarkSheet.

You can also do it the other way around:

find Class/ -name 'MarkSheet*' | while IFS= read -r mark; do 
  find "$(dirname "$mark")" -newer "$mark" -type f; 
done

The trick here is to use dirname to get the name of the directory containing the MarkSheet* file.

terdon
  • 252.3k
  • 69
  • 480
  • 718