ivaneeo's blog

          自由的力量,自由的生活。

            BlogJava :: 首頁 :: 聯系 :: 聚合  :: 管理
            669 Posts :: 0 Stories :: 64 Comments :: 0 Trackbacks
          當兩個人同時修改一個公用文件時,diff3就會發揮作用.它比較兩個人做出的兩套修改內容,創建第3個文件保存并后的輸出結果,并且指出雙方修改的沖突之處.diff3的語法是:
          diff [options] myfile oldfile yourfile
          oldfile是派生出myfile和yourfile的共同源文件.
            程序清單6.4 sigrot.1
              #!/bin/bash
              #sigrot.sh
              #Version 1.0
              #Rotate signatures
              #Suitable to be run via cron
              ############################
              sigfile=signature
              
              old=$(cat num)
              let new=$(expr $old+1)

              if [ -f $sigfile.$new ]; then
                cp $sigfile.$new .$sigfile
                echo $new > num
              else
                cp $sigfile.1 .$sigfile
                echo 1 > num
              fi

            程序清單6.5 sigrot.2
              #!/bin/bash
              #sigrot.sh
              #Version 2.0
              #Rotate signatures
              #Suitable to be run via cron
              ############################

              sigfile=signature
              srcdir=$HOME/doc/signatures
              srcfile=$srcdir/$sigfile
              old=$(cat $srcdir/num)
              let new=$(expr $old+1)

              if [ -f $srcfile.$new ]; then
                cp $srcfile.$new $HOME/.$sigfile
                echo $new > $srcdir/num
              else
                cp $srcfile.1 $HOME/.$sigfile
                echo 1 > $srcdir/num
              fi

            程序清單6.6 sigrot.3
              #!/bin/bash
              #sigrot.sh
              #Version 3.0
              #Rotate signatures
              #Suitable to be run via cron
              ############################

              sigfile=signature
              
              old=$(cat num)
              let new=$(expr $old+1)

              if [ -f $sigfile.$new ]; then
                cp $sigfile.$new .$sigfile
                echo $new > num
              else
                cp $sigfile.1 .$sigfile
                echo 1 > num
              fi
              return 0;

          diff3在列舉hunk的同時給出了生成這些hunk所需的一個或多個命令(仍舊使用ed形式).這些命令如下:
          .file:la  該hunk出現在第1行后,但在file中不存在這個hunk,所以如果要依據file生成其他文件,必須加入在第1行后這個hunk.
          .file:rc  該hunk由file的中第r行組成,因此在生成其他文件時必須對該行進行指定的修改.
          posted on 2005-08-04 17:16 ivaneeo 閱讀(273) 評論(0)  編輯  收藏 所屬分類: GNU牛力
          主站蜘蛛池模板: 牙克石市| 平顶山市| 彭山县| 甘南县| 金塔县| 津市市| 梁河县| 玉溪市| 任丘市| 女性| 丰都县| 易门县| 深圳市| 华安县| 汨罗市| 乌拉特后旗| 西昌市| 宜兰县| 潮安县| 洪江市| 扬州市| 舟曲县| 平潭县| 七台河市| 焉耆| 彰武县| 富民县| 翁牛特旗| 称多县| 安达市| 防城港市| 大同市| 兴化市| 广东省| 民丰县| 八宿县| 永川市| 吴旗县| 雷波县| 东莞市| 分宜县|