国产精品chinese,色综合天天综合精品网国产在线,成午夜免费视频在线观看,清纯女学生被强行糟蹋小说

    <td id="ojr13"><tr id="ojr13"><label id="ojr13"></label></tr></td>
        • <source id="ojr13"></source>
            <td id="ojr13"><ins id="ojr13"><label id="ojr13"></label></ins></td>

            Article / 文章中心

            Fdupes - 在 Linux 中查找和刪除重復(fù)文件的命令行工具

            發(fā)布時(shí)間:2022-04-11 點(diǎn)擊數(shù):1048
            Fdupes是由Adrian Lopez用C編程語言編寫的 Linux 實(shí)用程序,在 MIT 許可下發(fā)布。該應(yīng)用程序能夠在給定的目錄和子目錄集中找到重復(fù)文件。


            概述

            對(duì)于大多數(shù)計(jì)算機(jī)用戶來說,查找和替換重復(fù)文件是一個(gè)常見的要求。查找和刪除重復(fù)文件是一項(xiàng)繁重的工作,需要時(shí)間和耐心。如果你使用的系統(tǒng)是windows系統(tǒng),DuplicateFilesDeleter可以幫你輕松解決問題。如果你使用的是Linux系統(tǒng),你也不用擔(dān)心,查找重復(fù)文件也會(huì)是一件非常容易事情,這就是 fdupes 實(shí)用程序。

            編輯搜圖

            什么是 fdupes?

            Fdupes是由Adrian Lopez用C編程語言編寫的 Linux 實(shí)用程序,在 MIT 許可下發(fā)布。該應(yīng)用程序能夠在給定的目錄和子目錄集中找到重復(fù)文件。Fdupes 通過比較文件的 MD5 簽名,然后進(jìn)行逐字節(jié)比較來識(shí)別重復(fù)項(xiàng)。Fdupes 可以傳遞許多選項(xiàng)來列出、刪除和替換帶有重復(fù)文件的硬鏈接的文件。

            比較按順序開始:

            大小比較>部分 MD5 簽名比較>完整 MD5 簽名比較>逐字節(jié)比較。

            在 Linux 上安裝 fdupes

            在基于CentOS / RHEL和Fedora的系統(tǒng)上,您需要打開epel 存儲(chǔ)庫來安裝 fdupes 包。

            復(fù)制
            # yum install fdupes# dnf install fdupes [centos8]1.2.
            

            注意:從centos 8開始,默認(rèn)的包管理器yum被dnf取代.

            如何使用 fdupes 命令?

            復(fù)制
            $ fdupes -h用法: fdupes [options] 目錄...
             -r --recurse 為每個(gè)給定的目錄跟隨子目錄
                                內(nèi)遇到
             -R --recurse:對(duì)于在此選項(xiàng)之后給出的每個(gè)目錄,請(qǐng)遵循
                                內(nèi)遇到的子目錄(注意':'在
                                選項(xiàng)的結(jié)尾,更多詳細(xì)信息的手冊(cè)頁)
             -s --symlinks 跟隨符號(hào)鏈接
             -H --hardlinks 通常,當(dāng)兩個(gè)或多個(gè)文件指向同一個(gè)文件時(shí)
                                磁盤區(qū)域它們被視為非重復(fù);這
                                選項(xiàng)將改變這種行為
             -n --noempty 排除零長度文件
             -A --nohidden 排除隱藏文件
             -f --omitfirst 忽略每組匹配中的第一個(gè)文件 -1 --sameline 在一行中列出每組匹配項(xiàng)
             -S --size 顯示重復(fù)文件的大小
             -m --summarize 總結(jié)重復(fù)信息
             -q --quiet 隱藏進(jìn)度指示器
             -d --delete 提示用戶輸入要保留和刪除的所有文件
                                其他; 重要:在特定情況下,
                                一起使用此選項(xiàng)時(shí)可能會(huì)丟失數(shù)據(jù)
                                使用 -s 或 --symlinks,或者當(dāng)指定一個(gè)特定目錄不止一次;參考fdupes 文檔以獲取更多信息
             -N --noprompt 和 --delete 一起,保留第一個(gè)文件
                                每組重復(fù)并刪除其余的沒有提示用戶
             -v --version 顯示 fdupes 版本
             -h --help 顯示此幫助信息1.2.3.4.5.6.7.8.9.10.11.12.13.14.15.16.17.18.19.20.21.22.23.24.25.26.
            

            fdupes使用演示

            1、出于演示目的,讓我們?cè)谝粋€(gè)目錄下創(chuàng)建幾個(gè)重復(fù)文件,如下所示:

            復(fù)制
            mkdir /home/dba/test && cd /home/dba/test && for i in {1..15}; do echo "hello world" > file${i}.txt ; done1.
            

            運(yùn)行上述命令后,讓我們使用ls 命令驗(yàn)證是否創(chuàng)建了重復(fù)文件。

            復(fù)制
            [root@192_168_209_128 test]# ls -ltotal 60-rw-r--r-- 1 root root 12 Apr 10 23:02 file10.txt-rw-r--r-- 1 root root 12 Apr 10 23:02 file11.txt-rw-r--r-- 1 root root 12 Apr 10 23:02 file12.txt-rw-r--r-- 1 root root 12 Apr 10 23:02 file13.txt-rw-r--r-- 1 root root 12 Apr 10 23:02 file14.txt-rw-r--r-- 1 root root 12 Apr 10 23:02 file15.txt-rw-r--r-- 1 root root 12 Apr 10 23:02 file1.txt-rw-r--r-- 1 root root 12 Apr 10 23:02 file2.txt-rw-r--r-- 1 root root 12 Apr 10 23:02 file3.txt-rw-r--r-- 1 root root 12 Apr 10 23:02 file4.txt-rw-r--r-- 1 root root 12 Apr 10 23:02 file5.txt-rw-r--r-- 1 root root 12 Apr 10 23:02 file6.txt-rw-r--r-- 1 root root 12 Apr 10 23:02 file7.txt-rw-r--r-- 1 root root 12 Apr 10 23:02 file8.txt-rw-r--r-- 1 root root 12 Apr 10 23:02 file9.txt1.2.3.4.5.6.7.8.9.10.11.12.13.14.15.16.17.
            

            上面的腳本創(chuàng)建了15 個(gè)文件,即 file1.txt、file2.txt…file15.txt,每個(gè)文件都包含相同的數(shù)據(jù),即,

            復(fù)制
            "hello world"1.
            

            2、現(xiàn)在在文件夾test中搜索重復(fù)文件。

            復(fù)制
            [root@192_168_209_128 test]# fdupes /home/dba/test/home/dba/test/file1.txt                /home/dba/test/file2.txt/home/dba/test/file3.txt/home/dba/test/file4.txt/home/dba/test/file5.txt/home/dba/test/file6.txt/home/dba/test/file7.txt/home/dba/test/file8.txt/home/dba/test/file9.txt/home/dba/test/file10.txt/home/dba/test/file11.txt/home/dba/test/file12.txt/home/dba/test/file13.txt/home/dba/test/file14.txt/home/dba/test/file15.txt1.2.3.4.5.6.7.8.9.10.11.12.13.14.15.16.
            

            3、使用-r 選項(xiàng)在每個(gè)目錄(包括其子目錄)下遞歸搜索重復(fù)項(xiàng)。

            它遞歸地搜索所有文件和文件夾,具體取決于文件和文件夾的數(shù)量,掃描重復(fù)項(xiàng)需要一些時(shí)間。同時(shí),您將看到終端的總進(jìn)度,類似這樣。

            復(fù)制
            [root@192_168_209_128 test]#  fdupes -r /homeProgress [2544/3628] 70% 1.2.
            

            4、使用-S選項(xiàng)查看在文件夾中找到的重復(fù)項(xiàng)的大小。

            復(fù)制
            [root@192_168_209_128 test]# fdupes -S /home/dba/test12 bytes each:                          
            /home/dba/test/file1.txt/home/dba/test/file2.txt/home/dba/test/file3.txt/home/dba/test/file4.txt/home/dba/test/file5.txt/home/dba/test/file6.txt/home/dba/test/file7.txt/home/dba/test/file8.txt/home/dba/test/file9.txt/home/dba/test/file10.txt/home/dba/test/file11.txt/home/dba/test/file12.txt/home/dba/test/file13.txt/home/dba/test/file14.txt/home/dba/test/file15.txt1.2.3.4.5.6.7.8.9.10.11.12.13.14.15.16.17.
            

            5、您可以同時(shí)使用-S和-r選項(xiàng)查看遇到的每個(gè)目錄和子目錄的重復(fù)文件大小,如下所示:

            復(fù)制
            [root@192_168_209_128 test]# fdupes -Sr /home/dba/test |more315 bytes each:                         
            /home/dba/test/etc/firewalld/zones/public.xml/home/dba/test/etc/firewalld/zones/public.xml.old39 bytes each:
            /home/dba/test/etc/subuid-/home/dba/test/etc/subgid-4364 bytes each:
            /home/dba/test/etc/vmware-tools/poweroff-vm-default/home/dba/test/etc/vmware-tools/poweron-vm-default/home/dba/test/etc/vmware-tools/resume-vm-default/home/dba/test/etc/vmware-tools/suspend-vm-default984 bytes each:
            /home/dba/test/etc/sane.d/dc210.conf/home/dba/test/etc/sane.d/dc240.conf13 bytes each:
            /home/dba/test/etc/sane.d/s9036.conf/home/dba/test/etc/sane.d/nec.conf1 byte each:
            /home/dba/test/etc/at.deny/home/dba/test/etc/resolv.conf.save104 bytes each:
            /home/dba/test/etc/dconf/db/gdm/home/dba/test/etc/dconf/db/site/home/dba/test/etc/dconf/db/local4504 bytes each:--More--1.2.3.4.5.6.7.8.9.10.11.12.13.14.15.16.17.18.19.20.21.22.23.24.25.26.27.
            

            6、除了遞歸搜索一個(gè)文件夾或所有文件夾外,您可以根據(jù)需要選擇兩個(gè)文件夾或三個(gè)文件夾。更不用說,如果需要,您可以使用選項(xiàng)-S和/或-r。

            復(fù)制
            $ fdupes /home/avi/Desktop/ /home/avi/Templates/1.
            

            7、要在保留副本的同時(shí)刪除重復(fù)文件,您可以使用選項(xiàng)'-d'。使用此選項(xiàng)時(shí)應(yīng)格外小心,否則您可能最終會(huì)丟失必要的文件/數(shù)據(jù),并注意該過程是不可恢復(fù)的。

            復(fù)制
            [root@192_168_209_128 test]# fdupes -d /home/dba/test [1] /home/dba/test/file1.txt            [2] /home/dba/test/file2.txt[3] /home/dba/test/file3.txt[4] /home/dba/test/file4.txt[5] /home/dba/test/file5.txt[6] /home/dba/test/file6.txt[7] /home/dba/test/file7.txt[8] /home/dba/test/file8.txt[9] /home/dba/test/file9.txt[10] /home/dba/test/file10.txt[11] /home/dba/test/file11.txt[12] /home/dba/test/file12.txt[13] /home/dba/test/file13.txt[14] /home/dba/test/file14.txt[15] /home/dba/test/file15.txtSet 1 of 1, preserve files [1 - 15, all]: 1.2.3.4.5.6.7.8.9.10.11.12.13.14.15.16.17.
            

            您可能會(huì)注意到列出了所有重復(fù)項(xiàng),并提示您刪除,一個(gè)一個(gè)或某個(gè)范圍或一次全部刪除。您可以選擇類似下面的范圍來刪除特定范圍的文件文件。

            復(fù)制
            Set 1 of 1, preserve files [1 - 15, all]: 2-15
               [-] /home/dba/test/file1.txt
               [+] /home/dba/test/file2.txt
               [-] /home/dba/test/file3.txt
               [-] /home/dba/test/file4.txt
               [-] /home/dba/test/file5.txt
               [-] /home/dba/test/file6.txt
               [-] /home/dba/test/file7.txt
               [-] /home/dba/test/file8.txt
               [-] /home/dba/test/file9.txt
               [-] /home/dba/test/file10.txt
               [-] /home/dba/test/file11.txt
               [-] /home/dba/test/file12.txt
               [-] /home/dba/test/file13.txt
               [-] /home/dba/test/file14.txt
               [-] /home/dba/test/file15.txt1.2.3.4.5.6.7.8.9.10.11.12.13.14.15.16.
            

            8、從安全的角度來看,您可能希望將“fdupes”的輸出打印到文件中,然后檢查文本文件以確定要?jiǎng)h除的文件。這減少了意外刪除文件的機(jī)會(huì)。你可以這樣做:

            復(fù)制
            $ fdupes -Sr /home > /home/fdupes.txt1.
            

            注意:您可以將“/home”替換為您想要的文件夾。如果要分別搜索遞歸和打印大小,也可以使用選項(xiàng)“-r”和“-S” 。

            9、您可以使用選項(xiàng)-f省略每組匹配項(xiàng)中的第一個(gè)文件。

            首先列出目錄的文件。

            復(fù)制
            [root@192_168_209_128 test]# ls -l /home/dba/testtotal 60-rw-r--r-- 1 root root 12 Apr 10 23:22 file10.txt-rw-r--r-- 1 root root 12 Apr 10 23:22 file11.txt-rw-r--r-- 1 root root 12 Apr 10 23:22 file12.txt-rw-r--r-- 1 root root 12 Apr 10 23:22 file13.txt-rw-r--r-- 1 root root 12 Apr 10 23:22 file14.txt-rw-r--r-- 1 root root 12 Apr 10 23:22 file15.txt-rw-r--r-- 1 root root 12 Apr 10 23:22 file1.txt-rw-r--r-- 1 root root 12 Apr 10 23:22 file2.txt-rw-r--r-- 1 root root 12 Apr 10 23:22 file3.txt-rw-r--r-- 1 root root 12 Apr 10 23:22 file4.txt-rw-r--r-- 1 root root 12 Apr 10 23:22 file5.txt-rw-r--r-- 1 root root 12 Apr 10 23:22 file6.txt-rw-r--r-- 1 root root 12 Apr 10 23:22 file7.txt-rw-r--r-- 1 root root 12 Apr 10 23:22 file8.txt-rw-r--r-- 1 root root 12 Apr 10 23:22 file9.txt1.2.3.4.5.6.7.8.9.10.11.12.13.14.15.16.17.
            

            然后從每組匹配項(xiàng)中省略第一個(gè)文件。

            復(fù)制
            [root@192_168_209_128 test]# fdupes -f  /home/dba/test/home/dba/test/file2.txt                /home/dba/test/file3.txt/home/dba/test/file4.txt/home/dba/test/file5.txt/home/dba/test/file6.txt/home/dba/test/file7.txt/home/dba/test/file8.txt/home/dba/test/file9.txt/home/dba/test/file10.txt/home/dba/test/file11.txt/home/dba/test/file12.txt/home/dba/test/file13.txt/home/dba/test/file14.txt/home/dba/test/file15.txt1.2.3.4.5.6.7.8.9.10.11.12.13.14.15.
            

            10、檢查已安裝的 fdupes 版本。

            復(fù)制
            [root@192_168_209_128 test]#  fdupes -versionfdupes 1.6.1