screen instead of another location (such as when a program or command is
written in a way that already redirects those error messages to a file), use the
following:
Click here to view code image
matthew@seymour:~$ program 2>&1
Comparing Files
The two things users most commonly want to know when comparing two
files are what in the files is the same and what is different. This is especially
useful when comparing current versions of configuration files with backup
versions of the same files. There are commands to make these tasks easy.
Because looking for differences is more common, we start there.
Finding Differences in Files with diff
The diff command compares files line by line and outputs any lines that are
not identical. For example, this command outputs every line that is different
between two files:
Click here to view code image
matthew@seymour:~$ diff file1 file2
If file1 and file2 are different versions of a configuration file—say the
current file and a backup—the output quickly tells you what, if anything, has
changed. This can help when a config file is automatically updated during an
operating system upgrade or when you make a change that doesn’t work as
well as you had planned and then go back a couple weeks later to change the
configuration back.
There are several options you may use when running diff. (The original
UNIX-style versions, like -i, and the newer-style versions, like —ignore-
case, are identical in what they do; it might simply be easier for you to
remember one than the other.) Here are a few of the most useful ones to get
you started:
-i or –ignore-case—Ignores case differences in file contents
-b or –ignore-space-change—Ignores changes in the amount
of white space
-w or –ignore-all-space—Ignores all white space