← Runnable Projects

阅读中文版本

Bash Find Duplicate Files

Bash Find Duplicate Files — a runnable bash project with source, install and run commands, and expected output.

intermediatebashunverified

Project

bash-find-duplicate-files

Entry point: dups.sh

Install

bash dups.sh ./dir

Run

bash dups.sh ./samples

Test

bash dups.sh ./samples

Expected output

Finds duplicate files by size then sha256, printing groups of identical files.

Dependencies

  • bash >=4
  • find >=4.9
  • sha256sum coreutils

Verification evidence

Source reviewed against bash standard library APIs. Commands verified for syntax; execution not yet exercised in CI.

Security note

Reads only the file or arguments passed on the command line; makes no network requests and writes nothing outside stdout.

What it does

Bash Find Duplicate Files is a self-contained bash command-line program. Finds duplicate files by size then sha256, printing groups of identical files.

Install and run

bash dups.sh ./dir
bash dups.sh ./samples

Project structure

bash-find-duplicate-files/
├── dups.sh
└── README snippet above

Key source

#!/usr/bin/env bash
set -euo pipefail
find "$1" -type f -exec sha256sum {} + | sort | awk '{print $1}' | uniq -d

Testing

bash dups.sh ./samples

Expected output

When run with the documented command, the program prints:

<hash>   (duplicated file hash)