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.

up vote 8 down vote accepted

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

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.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.