Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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' '

share|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
add comment

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.

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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.