Chinaunix首页 | 论坛 | 博客
  • 博客访问: 936494
  • 博文数量: 192
  • 博客积分: 3070
  • 博客等级: 中校
  • 技术积分: 1861
  • 用 户 组: 普通用户
  • 注册时间: 2007-06-27 23:44
个人简介

Start Linux Leave Linux a while Back to Linux

文章分类

全部博文(192)

文章存档

2023年(18)

2022年(11)

2021年(8)

2020年(14)

2019年(7)

2018年(13)

2017年(16)

2016年(4)

2012年(2)

2011年(13)

2010年(26)

2009年(13)

2008年(27)

2007年(20)

我的朋友

分类:

2010-09-01 10:18:53

#cat diff_two_file
 
#/bin/sbin
file1=/mnt/mmc/test/aa
file2=/mnt/mmc/test/bb
 
diff $file1 $file2 > /dev/null
if [ $0 == 0 ]; then
    echo "Both file are same"
else
    echo "Both file are different"
fi
 
------------------------------------
 $0 是上一执行命令的返回值。
 diff 命令返回值为 0,说明两个文件相同, 否则两个文件不相同。
 
阅读(3565) | 评论(1) | 转发(0) |
给主人留下些什么吧!~~

chinaunix网友2011-04-19 01:34:37

$0 才不是上一条返回值 是$? 第一行应该是#!/bin/bash而且之前不能有空行