I Have duplicate file i need count of that files.

Example: example.html example(1).html

Output: i want the number of counts for example(1).htnl

  • 2
    i want the number of counts for example(1).htnl - the number is 1 - take it – RomanPerekhrest Jan 19 '18 at 10:45
  • 1
    Duplicates as in files whose contents are identical, or just ones with similar names (like those (N) tags)? – ilkkachu Jan 19 '18 at 11:23

Using fdupes:

fdupes -1 . | awk '{ print $1, NF }'

For an example directory:

$ fdupes -1 .  | awk '{ print $1, NF }'
./f 2
./file 2

In this example, there are two files with the same contents as f (f itself is included in that count), and likewise for file.

The -1 option for fdupes causes the output to be one line per group of identical files, and the awk code will print the first filename along with the count of identical files. The dot denotes "the current directory".

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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