/ Published in: Bash
Perl 1 liner + additional linux command to find duplicate files and remove it - only spare 1 file.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
#!/bin/sh find "$@" -type f -print0 | xargs -0 md5sum | sort | perl -ne 'chomp;$x=$y;($y,$z)=split(/\s+/,$_,2); print "$z"."\x00" if ($x eq $y)' | xargs -0 rm -v -- #OR #if wanna find out size of all files to calculate space storage #change the # xargs -0 stat -c %s | awk'{SUM+=$1}END{print SUM/1024/1024}'