Sometimes my students try to submit identical files for their homework. If they did their homework themselves, it would be impossible for any two files to be the exactly the same.
I put the homework in folders arranged like this: /section/id/
In this way, each section of the course has its own folder, each student has their own folder, and all of the files are within that last level. The student files come in a variety of formats.
- How can I check if there are any exactly identical files (ignoring file names) within any sub-folder?
This can help you identify exact same files from your students using the following
for loopandawkone-liner:Step: 1 –
for i in path/to/files; do cksum "$i"; done > cksum.txtStep: 2 –
awk 'NR==FNR && a[$1]++ { b[$1]; next } $1 in b' cksum.txt cksum.txtTest:
Some sample files in which
student 2has used identical file asstudent 1Step 1:
Create a cksum.txt file using the
cksumutilityStep 2:
Using
awkone-liner identify all files that are sameTest 2: