Re: [SLE] diff command and saving results to a file
-------------- Original message ---------------------- From: Scott Kitterman <opensuse@kitterman.com>
On Saturday 27 May 2006 10:37, lerninlinux@comcast.net wrote:
I have read the man page, and I think I am overlooking something, or am entering something wrong. I am trying to use the diff command, between a file on my pc, and one on my portable hard drive. Is there a way I can send the results to a txt file, or a file I could read in an editor? Or does this save the results automatically, and I just don't know where?
Diff will send the results where you tell it to. It sends the output to stdout, which is by default your shell screen. You can pipe the results to the text editor of you choice or directly to a file. For example, to use vim, you would do something like:
:~> diff [options, files, etc for diff] | vim
How do I pipe the results to the text file? Is that "|" the command?
On Saturday 27 May 2006 17:20, lerninlinux@comcast.net wrote:
How do I pipe the results to the text file? Is that "|" the command?
You don't pipe to a file, you pipe to a command. To a file you "redirect" To redirect the output to a file you use the > operator, for example diff -u file1 file2 > outputfile
On Sat, 27 May 2006 17:32:53 +0200 Anders Johansson <andjoh@rydsbo.net> wrote:
On Saturday 27 May 2006 17:20, lerninlinux@comcast.net wrote:
How do I pipe the results to the text file? Is that "|" the command?
You don't pipe to a file, you pipe to a command. To a file you "redirect"
To redirect the output to a file you use the > operator, for example
diff -u file1 file2 > outputfile
Just as a general point of information. Many of the Linux/Unix command line utilities were designed to be simple commands receiving input from the standard input, and output to standard output and errors to standard error. As Anders mentions, you can redirect to a text file, or pipe it into a utility. In general, the redirect operators are:
-- Redirect standard output to a file.
-- Append standard output to a file < - Redirect standard input from a file | - pipe the output to another program.
There are ways of redirecting standard error also, but they are a bit shell-centric and will be different on C-Shell derivatives and Bourne Shell derivatives. -- Jerry Feldman <gaf@blu.org> Boston Linux and Unix user group http://www.blu.org PGP key id:C5061EA9 PGP Key fingerprint:053C 73EC 3AC1 5C44 3E14 9245 FB00 3ED5 C506 1EA9
participants (3)
-
Anders Johansson
-
Jerry Feldman
-
lerninlinux@comcast.net