diff(1) 맨 페이지 - 윈디하나의 솔라나라




     diff - compare two files

     diff [-bitw] [-c | -e | -f | -h | -n | -u] file1 file2

     diff [-bitw] [-C number | -U number] file1 file2

     diff [-bitw] [-D string] file1 file2

     diff [-bitw] [-c | -e | -f | -h | -n | -u] [-l] [-r] [-s]
          [-S name] directory1 directory2

     The diff utility compares the contents of  file1  and  file2
     and  write to standard output a list of changes necessary to
     convert file1 into  file2.  This  list  should  be  minimal.
     Except  in  rare circumstances, diff finds a smallest suffi-
     cient set of file differences. No output is produced if  the
     files are identical.

     The normal output contains lines of these forms:

       n1 a n3,n4
       n1,n2 d n3
       n1,n2 c n3,n4

     where n1  and  n2  represent  lines  file1  and  n3  and  n4
     represent lines in file2 These lines resemble ed(1) commands
     to convert file1 to file2. By exchanging a for d and reading
     backward, file2 can be converted to file1. As in ed, identi-
     cal pairs, where n1=n2 or n3=n4, are abbreviated as a single

     Following each of these lines come all the  lines  that  are
     affected  in  the  first  file  flagged by `<', then all the
     lines that are affected in the second file flagged by `>'.

     The following options are supported:

           Ignores trailing blanks (spaces and tabs)  and  treats
           other strings of blanks as equivalent.

           Ignores the case of letters. For example, `A' compares
           equal to `a'.

           Expands TAB characters in output lines. Normal  or  -c
           output  adds  character(s)  to  the front of each line
           that can adversely affect the indentation of the  ori-
           ginal source lines and make the output lines difficult
           to  interpret.  This  option  preserves  the  original
           source's indentation.

           Ignores all blanks  (SPACE  and  TAB  characters)  and
           treats  all other strings of blanks as equivalent. For
           example, `if ( a == b )' compares equal to `if(a==b)'.

     The following options are mutually exclusive:

                  Produces a listing of  differences  with  three
                  lines of context. With this option, output for-
                  mat  is  modified  slightly.  That  is,  output
                  begins   with   identification   of  the  files
                  involved and their creation  dates,  then  each
                  change is separated by a line with a dozen *'s.
                  The lines removed from file1  are  marked  with
                  `-'.  The  lines added to file2 are marked `+'.
                  Lines that are changed from  one  file  to  the
                  other are marked in both files with `!'.

     -C number
                  Produces a listing of differences identical  to
                  that  produced  by -c with number lines of con-

     -D string
                  Creates a merged version  of  file1  and  file2
                  with C preprocessor controls included so that a
                  compilation  of  the  result  without  defining
                  string  is equivalent to compiling file1, while
                  defining string yields file2.

                  Produces a script of only a, c, and d  commands
                  for  the  editor ed, which recreates file2 from
                  file1. In connection with the  -e  option,  the
                  following  shell program can help maintain mul-
                  tiple versions of a  file.  Only  an  ancestral
                  file  ($1) and a chain of version-to-version ed
                  scripts ($2,$3,...) made by  diff  need  be  on
                  hand.  A  ``latest  version''  appears  on  the
                  standard output.

                    (shift; cat $*; echo a'1,$p') | ed - $1

                  Produces a similar script, not useful with  ed,
                  in the opposite order.

                  Does a fast, uninspired job.

                  This option only works when  changed  stretches
                  are  short  and well-separated. It does work on
                  files of unlimited length.

                  Only --b is available with -h.

                  diff does not  descend  into  directories  with
                  this option.

                  Produces a script similar to  -e,  but  in  the
                  opposite  order  and  with  a  count of changed
                  lines on each insert or delete command.

                  Produces a listing of  differences  with  three
                  lines of context. The output is similar to that
                  of the -c option, except that  the  context  is
                  "unified".  Removed  and changed lines in file1
                  are marked  by  a  `-'  while  lines  added  or
                  changed in file2 are marked by a `+'. Both ver-
                  sions of changed lines appear  in  the  output,
                  while  added, removed, and context lines appear
                  only once.  The  identification  of  file1  and
                  file2  is different, with "---" and "+++" being
                  printed where "***" and "---" would appear with
                  the  -c  option.  Each change is separated by a
                  line of the form

                    @@ -n1,n2 +n3,n4 @@

     -U number
                  Produces a listing of differences identical  to
                  that  produced  by -u with number lines of con-

     The following options are used for comparing directories:

                Produces output in long format. Before the  diff,
                each text file is piped through pr(1) to paginate
                it. Other differences are remembered and  summar-
                ized   after   all   text  file  differences  are

                Applies diff recursively to common subdirectories

                Reports files that are identical. These identical
                files would not otherwise be mentioned.

     -S name
                Starts a directory diff in the middle,  beginning
                with the file name.

     The following operands are supported:

                   A path name of a file or directory to be  com-
                   pared.  If  either  file1  or  file2 is -, the
                   standard input is used in its place.

                   A path name of a directory to be compared.

     If only one of file1 and  file2  is  a  directory,  diff  is
     applied  to the non-directory file and the file contained in
     the directory file with a filename that is the same  as  the
     last component of the non-directory file.

     See largefile(5) for the description of the behavior of diff
     when  encountering  files greater than or equal to 2 Gbyte (
     2^31 bytes).

     Example 1 Using the diff Command

     In the following command, dir1 is a directory  containing  a
     directory  named  x, dir2 is a directory containing a direc-
     tory named x, dir1/x and dir2/x  both  contain  files  named
     date.out, and dir2/x contains a file named y:

       example% diff -r dir1 dir2
       Common subdirectories: dir1/x and dir2/x

       Only in dir2/x: y

       diff -r dir1/x/date.out dir2/x/date.out


       < Mon Jul  2 13:12:16 PDT 1990


       > Tue Jun 19 21:41:39 PDT 1990

Environment Variables
     See environ(5) for descriptions of the following environment
     variables  that  affect the execution of diff: LANG, LC_ALL,

           Determines the locale for affecting the timezone  used
           for  calculating  file  timestamps written with the -C
           and -c options.

Exit Status
     The following exit values are returned:

           No differences were found.

           Differences were found.

           An error occurred.

                       Temporary file used for comparison

                       Executable file for the -h option

     See attributes(5) for descriptions of the  following  attri-
     tab() box; cw(2.75i) |cw(2.75i) lw(2.75i) |lw(2.75i)  ATTRI-
     BUTE  TYPEATTRIBUTE  VALUE  _  Availabilitysystem/core-os  _
     CSIEnabled  _  Interface  StabilityCommitted  _  StandardSee

See Also
     bdiff(1),  cmp(1),   comm(1),   dircmp(1),   ed(1),   pr(1),
     sdiff(1),  attributes(5),  environ(5),  largefile(5),  standards(5)

     Editing scripts produced under the  -e  or  -f  options  are
     naive  about  creating  lines  consisting of a single period

     Missing NEWLINE at end of file indicates that the last  line
     of the file in question did not have a NEWLINE. If the lines
     are different, they are flagged  and  output,  although  the
     output seems to indicate they are the same.
맨 페이지 내용의 저작권은 맨 페이지 작성자에게 있습니다.