Printing output to a text file on Linux

Hi, I am trying to get the difference between text files. There are many differences, and viewing them in the terminal makes it volatile, since I cannot save them. I want to view and save diff. How do I catch the output and print it in a text file?

The code I use to get diff is diff -i -w -B file1.txt file2.txt

+3
source share
3 answers

Save to text file:

diff -i -w -B file1.txt file2.txt > diff.txt

Recording directly to the printer:

diff -i -w -B file1.txt file2.txt | lpr

Writing a saved text file to the printer

lpr diff.txt

'Hope this helps .. PSM

PS: Here's a link to print on the Linux command line:

http://tldp.org/HOWTO/Printing-Usage-HOWTO-2.html

+7
source

, command > output.txt

diff -i -w -B file1.txt file2.txt > output.txt


command >> output.txt

+6

:

 diff -i -w -B file1.txt file2.txt > output.diff

If you want to know more about output redirection, the extended details change from shell to shell, but here is a link for bash and a cheat sheet for general redirects stdout / stderr.

+3
source

Source: https://habr.com/ru/post/1761527/


All Articles