-1

Try'd a lot of different commands, Diff / comm / grep / etc... But dont know how to manage this. It's for my bash script.

I want to get the result of the correct / incorrect answers. the example below should be 2 correct / 3 in-correct.

I have 2 files: 1: Correct-answers with this inside:

Answer A
Answer B
Answer C
Answer D
Answer A

2: Fill in with this inside:

Answer A
Answer R
Answer B
Answer D
Answer C

1 Answer 1

2

This is paste and gawk (you mentioned etc).

paste file1 file2 -d ',' | gawk 'BEGIN { FS="," } $1==$2{print "correct"} $1!=$2{print "incorrect"}'

paste just put the two together side by side

-d is for delimiter similarly FS means field separator. They have to be the same and some character that you don't have in your file (so not space which is default)

BEGIN means we're setting FS that just one time before we start.

It's output will be:

correct
incorrect
incorrect
correct
incorrect
1
  • Thnx for your answer!!! And sorry for offtopic.
    – Beginner
    May 7, 2015 at 10:16

Not the answer you're looking for? Browse other questions tagged .