1

From https://unix.stackexchange.com/a/277707/674

find . ! -empty -type f -exec md5sum {} + | sort | uniq -w32 -dD

can find duplicate files under the current directory.

What does -dD mean to uniq? I saw the meanings of -d and -D in manpage, but not sure what they mean when they are used together. Thanks.

Tim
  • 101,790

2 Answers2

8

TLDR Bottom line, they do nothing when used together; -dD is identical to -D.

Research

If you look at the case/switch logic of the uniq.c command you can see this first hand:

case 'd':
  output_unique = false;
  output_option_used = true;
  break;

case 'D':
  output_unique = false;
  output_later_repeated = true;
  if (optarg == NULL)
    delimit_groups = DM_NONE;
  else
    delimit_groups = XARGMATCH ("--all-repeated", optarg,
                                delimit_method_string,
                                delimit_method_map);
  output_option_used = true;
  break;

The way that this code is structured, if either -dD is set, ouput_unique is set to false; but more importantly, output_later_repeated is set to true.

Once that condition is set, output_later_repeated, there's no feasible way for -dD to have anything but identical output to -D.

Incidentally, the computerhope man page has a better table that explains the -d and -D switches.

References

Jeff Schaller
  • 67,283
  • 35
  • 116
  • 255
slm
  • 369,824
4

The uniq -dD makes no sense - it's equivalent of uniq -D. Both -dD and -D will produce always same result since -d's output set is a subset of -D.

Bob
  • 1,155