免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 2096 | 回复: 9

比较文件 [复制链接]

论坛徽章:
0
发表于 2003-02-24 11:11 |显示全部楼层
FILE A  和 FILE B

比较两个 FILES

输出 相同的。。。

谁能给一个。。

论坛徽章:
0
发表于 2003-02-24 11:37 |显示全部楼层

比较文件

这是一个用shell程序实现的方案
diff file1 fil2 >tmpfile
sed -n -e '5,/^---/p' tmpfile >a
sed -e '/^!/d' a >targetfile

论坛徽章:
0
发表于 2003-02-24 11:38 |显示全部楼层

比较文件

这个方法比较苯,但能解决问题,只要稍微改动一下就可当做shell命令使用!

论坛徽章:
0
发表于 2003-02-24 11:40 |显示全部楼层

比较文件

let me try it 。。

thanks man

论坛徽章:
0
发表于 2003-02-24 11:54 |显示全部楼层

比较文件

comm  -12  filea  fileb

论坛徽章:
0
发表于 2003-02-24 12:36 |显示全部楼层

比较文件

sort filea > filec
sort fileb > filed
comm -12 filec filed

论坛徽章:
0
发表于 2003-02-24 13:07 |显示全部楼层

比较文件

哈哈!
果然还有更好的!
谢谢!

论坛徽章:
0
发表于 2003-02-24 14:46 |显示全部楼层

比较文件

Learn "one hand" from    biansj *_~
User Commands                                             comm(1)

NAME
     comm - select or reject lines common to two files

SYNOPSIS
     comm  [ -123 ] file1 file2

DESCRIPTION
     The comm  utility will read file1 and file2, which should be
     ordered in the current collating sequence, and produce three
     text columns as output: lines only in file1; lines  only  in
     file2; and lines in both files.

     If the input files were ordered according to  the  collating
     sequence of the current locale, the lines written will be in
     the collating sequence of the original lines.  If  not,  the
     results are unspecified.

OPTIONS
     The following options are supported:

     -1        Suppress the output  column  of  lines  unique  to
               file1.

     -2        Suppress the output  column  of  lines  unique  to
               file2.

     -3        Suppress the output column of lines duplicated  in
               file1 and file2.

OPERANDS
     The following operands are supported:

     file1     A path name of the first file to be  compared.  If
               file1 is -, the standard input is used.

     file2     A path name of the second file to be compared.  If
               file2 is -, the standard input is used.

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

EXAMPLES
     Example 1: Printing a list of utilities specified by files.

     If file1, file2, and file3 each contained a sorted  list  of
     utilities:

     example% comm -23 file1 file2  | comm -23 - file3
     would print a list of utilities in file1  not  specified  by
     either of the other files;
User Commands                                             comm(1)

     example% comm -12 file1 file2 | comm -12 - file3
     would print a list  of  utilities  specified  by  all  three
     files; and
     example% comm -12  file2 file3 | comm -23 -file1
     would print a list of utilities specified by both file2  and
     file3, but not specified in file1.

ENVIRONMENT VARIABLES
     See environ(5) for descriptions of the following environment
     variables  that  affect  the execution of comm : LC_COLLATE,
     LC_CTYPE, LC_MESSAGES, and NLSPATH.

EXIT STATUS
     The following exit values are returned:

     0         All input files were successfully output as speci-
               fied.

     >0        An error occurred.

论坛徽章:
0
发表于 2003-02-24 19:57 |显示全部楼层

比较文件

thanks man ..

i had solved the problem .

论坛徽章:
0
发表于 2003-02-25 17:59 |显示全部楼层

比较文件

请记住一条,比较前,先排序
                
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP