Skip to main content
fixed a few quoting issues
Source Link
Stéphane Chazelas
  • 584.9k
  • 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*"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*'MarkSheet*' | while IFS= read -r mark; do 
  find "$(dirname $mark"$mark")" -newer "$mark" -type f; 
done

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

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.

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.

added 27 characters in body
Source Link
terdon
  • 252.3k
  • 69
  • 480
  • 718

Try this:

for student in $(find /Class/ -maxdepth 1 -mindepth 1 -type d); do| 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:

for mark in $(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.

Try this:

for student in $(find /Class/ -maxdepth 1 -mindepth 1 -type d); 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:

for mark in $(find Class/ -name MarkSheet*); 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.

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.

Source Link
terdon
  • 252.3k
  • 69
  • 480
  • 718

Try this:

for student in $(find /Class/ -maxdepth 1 -mindepth 1 -type d); 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:

for mark in $(find Class/ -name MarkSheet*); 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.