>/tmp/check.txt for file in `ls *.py` do awk -F "(" '{ if ($0 ~ /^def/) { print $0 } }' $file >> /tmp/check.txt done python <<! f = file("/tmp/check.txt", "r") lines = f.readlines() unique=set(lines) if len(lines) != len(unique): for n in unique: lines.remove(n) print "=== duplicate function ===" for l in lines: print l.strip() !
从*.py文件中找重复的代码。