¶ Introduction
I recently started using the command line to correct MCQs. Here’s my setup.
¶ Prerequisites
The only prerequisites are the diff
and nl
unix utilities, along with a digitised answer key.
¶ Basic Usage
Let us assume two files:
answer_key
a
b
a
c
d
a
a
c
b
d
answer_sheet
a
b
a
c
d
d
c
c
a
d
You can easily diff them:
diff answer_sheet answer_key
6,8d5
< d
< c
< c
9a7,9
> a
> c
> b
However, this output is not very readable.
¶ Improving The Usability
Using nl
to add line numbers to the files, along with some flags for diff
, we can get a prettier output (NOTE: This uses file descriptors and thus requires bash):
diff <(nl answer_sheet) <(nl answer_key) -y --suppress-common-lines
6 d | 6 a
7 c | 7 a
9 a | 9 b
As you can see, this output is much easier to understand, and only the mistakes.