In Linux,I have questions in one file and questions and answers in other file .How to diff both files and extract only answers in separate file?

Viewed 17

My file1.txt contains data as Q1. How to check whether a file is being modified or not by somebody? Ans.Check md5 number

Q2. What command is used to show the unique id attached with each file . Ans.ls –li

While file2.txt contains data as Q1. How to check whether a file is being modified or not by somebody? Q2. What command is used to show the unique id attached with each file .

Expected outcome: file3.txt containing answers Ans.Check md5 number Ans.ls -li

1 Answers

Try to use the diff command and redirect the result to a third file: diff file1.txt file2.txt > file3.txt

you can read other option of diff like this: man diff

I hope could help!

Related