-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

closed as off-topic by masegaloeh, Cristian Ciupitu, kasperd, fukawi2, mdpc May 7 '15 at 1:55

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions on Server Fault must be about managing information technology systems in a business environment. Home and end-user computing questions may be asked on Super User, and questions about development, testing and development tools may be asked on Stack Overflow." – kasperd, mdpc
If this question can be reworded to fit the rules in the help center, please edit the question.

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
  • Thnx for your answer!!! And sorry for offtopic. – Beginner May 7 '15 at 10:16

Not the answer you're looking for? Browse other questions tagged or ask your own question.