How to get the result on another file after applying diff to file A.txt and B.txt.
Suppose File A.txt has:
a
b
c
File B.txt has:
a
b
on running
diff A.txt B.txt
It gives result as c, but how to store it in a file C.txt?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The
diffutility produces its output on standard output (usually the console). Like any UNIX utility that does this, its output may very simply be redirected into a file like this:This means “execute the command
diffwith two arguments (the filesA.txtandB.txt) and put everything that would otherwise be displayed on the console into the fileC.txt“. Error messages will still go to the console.To save the output of
diffto a file and also send it to the terminal, useteelike so:tee will duplicate the data to all named files (only
C.txthere) and also to standard output (most likely the terminal).