<del id="d4fwx"><form id="d4fwx"></form></del>
      <del id="d4fwx"><form id="d4fwx"></form></del><del id="d4fwx"><form id="d4fwx"></form></del>

            <code id="d4fwx"><abbr id="d4fwx"></abbr></code>
          • ruh在Linux上識別同樣內(nèi)容的文件

            小編給大家分享一下ruh 在Linux上識別同樣內(nèi)容的文件,希望大家閱讀完這篇文章之后都有所收獲,下面讓我們一起去探討吧!

            按需定制開發(fā)可以根據(jù)自己的需求進(jìn)行定制,網(wǎng)站制作、成都網(wǎng)站制作構(gòu)思過程中功能建設(shè)理應(yīng)排到主要部位公司網(wǎng)站制作、成都網(wǎng)站制作的運(yùn)用實際效果公司網(wǎng)站制作網(wǎng)站建立與制做的實際意義

            用 diff 命令比較文件

            可能比較兩個文件最簡單的方法是使用 diff 命令。輸出會顯示你文件的不同之處。 < 和 > 符號代表在當(dāng)參數(shù)傳過來的第一個( < )或第二個( > )文件中是否有額外的文字行。在這個例子中,在 backup.html 中有額外的文字行。

            $ diff index.html backup.html
            2438a2439,2441
            > <pre>
            > That's all there is to report.
            > </pre>

            如果 diff 沒有輸出那代表兩個文件相同。

            $ diff home.html index.html
            $

            diff 的唯一缺點(diǎn)是它一次只能比較兩個文件并且你必須指定用來比較的文件,這篇帖子中的一些命令可以為你找到多個重復(fù)文件。

            使用校驗和

            cksum (checksum) 命令計算文件的校驗和。校驗和是一種將文字內(nèi)容轉(zhuǎn)化成一個長數(shù)字(例如2819078353 228029)的數(shù)學(xué)簡化。雖然校驗和并不是完全獨(dú)有的,但是文件內(nèi)容不同校驗和卻相同的概率微乎其微。

            $ cksum *.html
            2819078353 228029 backup.html
            4073570409 227985 home.html
            4073570409 227985 index.html

            在上述示例中,你可以看到產(chǎn)生同樣校驗和的第二個和第三個文件是如何可以被默認(rèn)為相同的。

            使用 find 命令

            雖然 find 命令并沒有尋找重復(fù)文件的選項,它依然可以被用來通過名字或類型尋找文件并運(yùn)行 cksum 命令。例如:

            $ find . -name "*.html" -exec cksum {} \;
            4073570409 227985 ./home.html
            2819078353 228029 ./backup.html
            4073570409 227985 ./index.html

            使用 fslint 命令

            fslint 命令可以被特地用來尋找重復(fù)文件。注意我們給了它一個起始位置。如果它需要遍歷相當(dāng)多的文件,這就需要花點(diǎn)時間來完成。注意它是如何列出重復(fù)文件并尋找其它問題的,比如空目錄和壞 ID。

            $ fslint .
            -----------------------------------file name lint
            -------------------------------Invalid utf8 names
            -----------------------------------file case lint
            ----------------------------------DUPlicate files  <==
            home.html
            index.html
            -----------------------------------Dangling links
            --------------------redundant characters in links
            ------------------------------------suspect links
            --------------------------------Empty Directories
            ./.gnupg
            ----------------------------------Temporary Files
            ----------------------duplicate/conflicting Names
            ------------------------------------------Bad ids
            -------------------------Non Stripped executables

            你可能需要在你的系統(tǒng)上安裝 fslint 。你可能也需要將它加入你的命令搜索路徑:

            $ export PATH=$PATH:/usr/share/fslint/fslint

            使用 rdfind 命令

            rdfind 命令也會尋找重復(fù)(相同內(nèi)容的)文件。它的名字意即“重復(fù)數(shù)據(jù)搜尋”,并且它能夠基于文件日期判斷哪個文件是原件——這在你選擇刪除副本時很有用因為它會移除較新的文件。

            $ rdfind ~
            Now scanning "/home/shark", found 12 files.
            Now have 12 files in total.
            Removed 1 files due to nonunique device and inode.
            Total size is 699498 bytes or 683 KiB
            Removed 9 files due to unique sizes from list.2 files left.
            Now eliminating candidates based on first bytes:removed 0 files from list.2 files left.
            Now eliminating candidates based on last bytes:removed 0 files from list.2 files left.
            Now eliminating candidates based on sha1 checksum:removed 0 files from list.2 files left.
            It seems like you have 2 files that are not unique
            Totally, 223 KiB can be reduced.
            Now making results file results.txt

            你可以在 dryrun 模式中運(yùn)行這個命令 (換句話說,僅僅匯報可能會另外被做出的改動)。

            $ rdfind -dryrun true ~
            (DRYRUN MODE) Now scanning "/home/shark", found 12 files.
            (DRYRUN MODE) Now have 12 files in total.
            (DRYRUN MODE) Removed 1 files due to nonunique device and inode.
            (DRYRUN MODE) Total size is 699352 bytes or 683 KiB
            Removed 9 files due to unique sizes from list.2 files left.
            (DRYRUN MODE) Now eliminating candidates based on first bytes:removed 0 files from list.2 files left.
            (DRYRUN MODE) Now eliminating candidates based on last bytes:removed 0 files from list.2 files left.
            (DRYRUN MODE) Now eliminating candidates based on sha1 checksum:removed 0 files from list.2 files left.
            (DRYRUN MODE) It seems like you have 2 files that are not unique
            (DRYRUN MODE) Totally, 223 KiB can be reduced.
            (DRYRUN MODE) Now making results file results.txt

            rdfind 命令同樣提供了類似忽略空文檔( -ignoreempty )和跟蹤符號鏈接( -followsymlinks )的功能。查看 man 頁面獲取解釋。

            -ignoreempty    ignore empty files
            -minsize    ignore files smaller than speficied size
            -followsymlinks   follow symbolic links
            -removeidentinode  remove files referring to identical inode
            -checksum    identify checksum type to be used
            -deterministic   determiness how to sort files
            -makesymlinks    turn duplicate files into symbolic links
            -makehardlinks   replace duplicate files with hard links
            -makeresultsfile  create a results file in the current directory
            -outputname   provide name for results file
            -deleteduplicates  delete/unlink duplicate files
            -sleep     set sleep time between reading files (milliseconds)
            -n, -dryrun   display what would have been done, but don't do it

            注意 rdfind 命令提供了 -deleteduplicates true 的設(shè)置選項以刪除副本。希望這個命令語法上的小問題不會惹惱你。;-)

            $ rdfind -deleteduplicates true .
            ...
            Deleted 1 files.  <==

            你將可能需要在你的系統(tǒng)上安裝 rdfind 命令。試驗它以熟悉如何使用它可能是一個好主意。

            使用 fdupes 命令

            fdupes 命令同樣使得識別重復(fù)文件變得簡單。它同時提供了大量有用的選項——例如用來迭代的 -r 。在這個例子中,它像這樣將重復(fù)文件分組到一起:

            $ fdupes ~
            /home/shs/UPGRADE
            /home/shs/mytwin
            
            /home/shs/lp.txt
            /home/shs/lp.man
            
            /home/shs/penguin.png
            /home/shs/penguin0.png
            /home/shs/hideme.png

            這是使用迭代的一個例子,注意許多重復(fù)文件是重要的(用戶的 .bashrc 和 .profile 文件)并且不應(yīng)被刪除。

            # fdupes -r /home
            /home/shark/home.html
            /home/shark/index.html
            
            /home/dory/.bashrc
            /home/eel/.bashrc
            
            /home/nemo/.profile
            /home/dory/.profile
            /home/shark/.profile
            
            /home/nemo/tryme
            /home/shs/tryme
            
            /home/shs/arrow.png
            /home/shs/PNGs/arrow.png
            
            /home/shs/11/files_11.zip
            /home/shs/ERIC/file_11.zip
            
            /home/shs/penguin0.jpg
            /home/shs/PNGs/penguin.jpg
            /home/shs/PNGs/penguin0.jpg
            
            /home/shs/Sandra_rotated.png
            /home/shs/PNGs/Sandra_rotated.png

            fdupe 命令的許多選項列如下。使用 fdupes -h 命令或者閱讀 man 頁面獲取詳情。

            -r --recurse   recurse
            -R --recurse:  recurse through specified directories
            -s --symlinks  follow symlinked directories
            -H --hardlinks  treat hard links as duplicates
            -n --noempty   ignore empty files
            -f --omitfirst  omit the first file in each set of matches
            -A --nohidden  ignore hidden files
            -1 --sameline  list matches on a single line
            -S --size    show size of duplicate files
            -m --summarize  summarize duplicate files information
            -q --quiet    hide progress indicator
            -d --delete   prompt user for files to preserve
            -N --noprompt  when used with --delete, preserve the first file in set
            -I --immediate  delete duplicates as they are encountered
            -p --permissions don't soncider files with different owner/group or
                     permission bits as duplicates
            -o --order=WORD order files according to specification
            -i --reverse   reverse order while sorting
            -v --version   display fdupes version
            -h --help    displays help

            fdupes 命令是另一個你可能需要安裝并使用一段時間才能熟悉其眾多選項的命令。

            看完了這篇文章,相信你對“ruh 在Linux上識別同樣內(nèi)容的文件”有了一定的了解,如果想了解更多相關(guān)知識,歡迎關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道,感謝各位的閱讀!

            網(wǎng)站名稱:ruh在Linux上識別同樣內(nèi)容的文件
            文章地址:http://www.jbt999.com/article46/gseohg.html

            成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供小程序開發(fā)、虛擬主機(jī)云服務(wù)器、域名注冊、網(wǎng)站設(shè)計公司、做網(wǎng)站

            廣告

            聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:[email protected]。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)

            微信小程序開發(fā)

              <del id="d4fwx"><form id="d4fwx"></form></del>
              <del id="d4fwx"><form id="d4fwx"></form></del><del id="d4fwx"><form id="d4fwx"></form></del>

                    <code id="d4fwx"><abbr id="d4fwx"></abbr></code>
                  • 夜夜躁婷婷 | 中文字幕+乱码+中文ktv | 亚洲免费在线视频播放 | 中文字幕 - 色网 | 五月天激情乱伦小说 |