I would to write a bash script to find duplicate files but I don't want just use md5sum. It means, in addition to use md5sum I want to check my files with cmp command.

I use the command below for finding duplicate files. Right now I need to write a loop and use cmp command for finding duplicates. How can I write a loop and write a bash script?

find . -type f | xargs -I% md5sum % | sort | uniq -w32 -D| cut -f3 -d' '

link|improve this question
2  
what is leading you to do cmp in addition of md5sum ? Are you afraid of hash collision ? – Cédric Julien Oct 5 '11 at 12:43
No this is my assignment and i have to write a bash script and find duplicate file – Elham abbasi Oct 5 '11 at 12:45
Question also exists on unix&linux SE – glenn jackman Oct 5 '11 at 13:41
feedback

migrated from stackoverflow.com Oct 5 '11 at 22:11

This question came from our site for professional and enthusiast programmers.

1 Answer

Give this short introduction to Bash a look.

If you wrote the one-liner in your question, the first part will be quite boring for you, but you can just skip to the Control structures section. The basic tools for flow control (if/for/while/do...while) are described there, with nice examples.

link|improve this answer
thank you, it is useful for me – Elham abbasi Oct 5 '11 at 13:03
feedback

Your Answer

 
or
required, but never shown