How i can find identical files using a hash and then display the path to them and their access rights?

Karl
find ./ -type f -print0|xargs -0 md5sum |sort -k1,32|uniq -w32 -D 

find "." -type f -printf  "%i %p %s %t  %M\n"

I have two unrelated scripts. I tried to connect them, but nothing works for me

ilkkachu

The first prints something like

b1946ac92492d2347c6235b4d2611184  ./one/two/a.txt
b1946ac92492d2347c6235b4d2611184  ./some/c.txt

So we could continue by cutting off the first 34 characters, which leaves the paths, one per line. And if you have GNU xargs, that could then be processed with xargs -d '\n' which could run e.g. ls on them. Or find.

$ find ./ -type f -print0|xargs -0 md5sum |sort |uniq -w32 -D |cut -c35- |xargs -d '\n' ls -ld
-rw-r--r-- 1 me me 6 Apr 12 22:38 ./one/two/a.txt
-rw-r--r-- 1 me me 6 Apr 12 22:38 ./some/c.txt

$ find ./ -type f -print0|xargs -0 md5sum |sort |uniq -w32 -D |cut -c35- |xargs -I{} -d '\n' find {} -printf  "%i %p %s %t  %M\n"
1706523 ./one/two/a.txt 6 Mon Apr 12 22:38:18.6494036350 2021  -rw-r--r--
1710394 ./some/c.txt 6 Mon Apr 12 22:38:24.8373114680 2021  -rw-r--r--

(sort -k1,32 would sort on the first and 32nd space-separated field, not on the first 32 characters. The hash is at the start of the string, so the default sort should work.)

Note that if you have filenames with newlines in them, xargs -d '\n' won't do. But if that's an issue, you'll need more modifications since the output of md5sum also changes when it encounters names like that. E.g. I get

$ md5sum $'new\nline'
\b1946ac92492d2347c6235b4d2611184  new\nline

with the leading backslash.

この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。

侵害の場合は、連絡してください[email protected]

編集
0

コメントを追加

0

関連記事

分類Dev

How can I recursively find all files and display the full path and line number using cmd?

分類Dev

How can I find the differences in visually identical PDF files?

分類Dev

How can i get all files on disk with a specific extension using 'Directory.getFiles' and save them in a list

分類Dev

How can I list files with find and Perl?

分類Dev

How can I reorganize files by extension, and sort them into folders by category?

分類Dev

How can I find the duplicated elements in a array and replace them?

分類Dev

How can I access path variables in my custom HandlerMethodArgumentResolver

分類Dev

How can I access path variables in my custom HandlerMethodArgumentResolver

分類Dev

How can I find and copy using gsutil?

分類Dev

How can I switch between fstream files without closing them (Simultaneous output files) - C++

分類Dev

Using Powershell and Test-Path, how can I tell the difference between a "folder doesn't exist" and "access denied"

分類Dev

V-For Image paths cannot find image. How can I add the correct file path when using v-for?

分類Dev

How do I save objects that I push into an array, then display them using local storage?

分類Dev

How can I access files (images) in an azureml FileDataSet?

分類Dev

How to use group rights access

分類Dev

How can I access value of ID to find the average?

分類Dev

How can I find the firewall program blocking access to SMB share

分類Dev

How can I find all files that do NOT contain a text string?

分類Dev

How Can I list files in the same order that flyway executes them in bash?

分類Dev

How Can I list files in the same order that flyway executes them in bash?

分類Dev

Where does active storage store files (on disk), and how can I retrieve them physically?

分類Dev

How can I compile multiple C++ files to use them with Python ctypes?

分類Dev

How can I copy files with common names and paste them into another folder?

分類Dev

How can I read tsv files and store them as hdf5 without running out of memory?

分類Dev

How can I use regex to find if a string has 2 specific characters and remove them if they are?

分類Dev

Does Canonical track Ubuntu usage? If so, how? Are there "official" figures? Where can I find them?

分類Dev

How do I validate an access token using the at_hash claim of an id token?

分類Dev

How can I upload multiple files using JavaScript and FastAPI?

分類Dev

How can I find application using hard drive?

Related 関連記事

  1. 1

    How can I recursively find all files and display the full path and line number using cmd?

  2. 2

    How can I find the differences in visually identical PDF files?

  3. 3

    How can i get all files on disk with a specific extension using 'Directory.getFiles' and save them in a list

  4. 4

    How can I list files with find and Perl?

  5. 5

    How can I reorganize files by extension, and sort them into folders by category?

  6. 6

    How can I find the duplicated elements in a array and replace them?

  7. 7

    How can I access path variables in my custom HandlerMethodArgumentResolver

  8. 8

    How can I access path variables in my custom HandlerMethodArgumentResolver

  9. 9

    How can I find and copy using gsutil?

  10. 10

    How can I switch between fstream files without closing them (Simultaneous output files) - C++

  11. 11

    Using Powershell and Test-Path, how can I tell the difference between a "folder doesn't exist" and "access denied"

  12. 12

    V-For Image paths cannot find image. How can I add the correct file path when using v-for?

  13. 13

    How do I save objects that I push into an array, then display them using local storage?

  14. 14

    How can I access files (images) in an azureml FileDataSet?

  15. 15

    How to use group rights access

  16. 16

    How can I access value of ID to find the average?

  17. 17

    How can I find the firewall program blocking access to SMB share

  18. 18

    How can I find all files that do NOT contain a text string?

  19. 19

    How Can I list files in the same order that flyway executes them in bash?

  20. 20

    How Can I list files in the same order that flyway executes them in bash?

  21. 21

    Where does active storage store files (on disk), and how can I retrieve them physically?

  22. 22

    How can I compile multiple C++ files to use them with Python ctypes?

  23. 23

    How can I copy files with common names and paste them into another folder?

  24. 24

    How can I read tsv files and store them as hdf5 without running out of memory?

  25. 25

    How can I use regex to find if a string has 2 specific characters and remove them if they are?

  26. 26

    Does Canonical track Ubuntu usage? If so, how? Are there "official" figures? Where can I find them?

  27. 27

    How do I validate an access token using the at_hash claim of an id token?

  28. 28

    How can I upload multiple files using JavaScript and FastAPI?

  29. 29

    How can I find application using hard drive?

ホットタグ

アーカイブ