23 lines
595 B
Plaintext
23 lines
595 B
Plaintext
|
#!/usr/bin/python
|
||
|
#
|
||
|
# by Erik osheim
|
||
|
import optparse, os
|
||
|
|
||
|
epilog = 'Remove various junky files left lying around.'
|
||
|
patterns = ('*~', '.#*', '#*', '*.orig', '*-')
|
||
|
|
||
|
parser = optparse.OptionParser(epilog=epilog)
|
||
|
parser.add_option('-f', '--fake', dest='fake', action='store_true',
|
||
|
help="print files; do not remove them")
|
||
|
opts, args = parser.parse_args()
|
||
|
|
||
|
stanzas = ' -o '.join(["-name '%s'" % x for x in patterns])
|
||
|
cmd = "find . -type f \\( %s \\) -print" % stanzas
|
||
|
|
||
|
if opts.fake:
|
||
|
print "files that would be deleted:"
|
||
|
else:
|
||
|
cmd += " -exec rm {} ';'";
|
||
|
|
||
|
os.system(cmd)
|