```
czkawka_cli dup --dryrun -d $(pwd)/folder -m1 -D aen
Found 2 duplicated files in 1 groups with same content which took 2 B:
Size - 2 B (2) - 2 files
/home/thomas/Development/czkawka/folder/a
/home/thomas/Development/czkawka/folder/b
----
-------------------------------MESSAGES--------------------------------
Delete /home/thomas/Development/czkawka/folder/a
Delete /home/thomas/Development/czkawka/folder/b
---------------------------END OF MESSAGES-----------------------------
```
This is a proof of concept.
```
$ echo a > hardlinks/a
$ cp hardlinks/{a,b}
$ ln hardlinks/{a,c}
$ cargo run --bin czkawka_cli dup -m 1 --directories $(pwd)/hardlinks -f /dev/stderr > /dev/null
-------------------------------------------------Files with same hashes-------------------------------------------------
Found 1 duplicated files which in 1 groups which takes 2 B.
---- Size 2 B (2) - 2 files
/home/thomas/Development/czkawka/hardlinks/a
/home/thomas/Development/czkawka/hardlinks/b
```
Open:
- Windows support
- Probably this should be a cli option
If the user could not create a hard link (due to permissions or
different block devices) then czkawka lost the duplicate file.
```
$ mkdir hardlink
$ cd hardlink
$ echo a > a
$ cp a b
$ chown thetestuser:thetestuser a
$ ls -il .
25169246 -rw-rw-r-- 1 thetestuser thetestuser 2 Feb 7 11:18 a
25169641 -rw-rw-r-- 1 thomas thomas 2 Feb 7 11:18 b
$ cargo run --bin czkawka_cli dup --directories $(pwd) -m 1 -f
test101.result --delete-method HARD
[...]
-------------------------------WARNINGS--------------------------------
Failed to link /home/thomas/Development/czkawka/hardlink/b ->
/home/thomas/Development/czkawka/hardlink/a
---------------------------END OF WARNINGS-----------------------------
$ ls -il .
25169246 -rw-rw-r-- 1 thetestuser thetestuser 2 Feb 7 11:18 a
```
Now czkawka keeps all files and the warning provides more information
why czkawka can't replace the duplicate with a hard link.
```
$ cargo run --bin czkawka_cli dup --directories $(pwd) -m 1 -f
test101.result --delete-method HARD
-------------------------------WARNINGS--------------------------------
Failed to link /home/thomas/Development/czkawka/hardlink/b ->
/home/thomas/Development/czkawka/hardlink/a (Operation not permitted (os
error 1))
---------------------------END OF WARNINGS-----------------------------
[...]
25169246 -rw-rw-r-- 1 thetestuser thetestuser 2 Feb 7 11:18 a
25169641 -rw-rw-r-- 1 thomas thomas 2 Feb 7 11:18 b
```
This results in the same space saving but keeps the "deleted" files around.
$ mkdir hardlink
$ cd hardlink
$ echo a > a
$ cp a b
$ ln a c
$ touch -t 01010000 a
$ ls -il --time-style=full-iso .
25169323 -rw-rw-r-- 2 thomas thomas 2 2021-01-01 00:00:00.000000000 +0100 a
25169558 -rw-rw-r-- 1 thomas thomas 2 2021-01-31 18:11:08.298161098 +0100 b
25169323 -rw-rw-r-- 2 thomas thomas 2 2021-01-01 00:00:00.000000000 +0100 c
$ czkawka_cli dup --directories $(pwd)/hardlink -m 1 -f hardlink.result --delete-method HARD
$ ls --time-style=full-iso -li hardlink
25169323 -rw-rw-r-- 3 thomas thomas 2 2021-01-01 00:00:00.000000000 +0100 a
25169323 -rw-rw-r-- 3 thomas thomas 2 2021-01-01 00:00:00.000000000 +0100 b
25169323 -rw-rw-r-- 3 thomas thomas 2 2021-01-01 00:00:00.000000000 +0100 c