Skip to content

Instantly share code, notes, and snippets.

@elee
Created June 8, 2011 19:24
Show Gist options
  • Save elee/1015155 to your computer and use it in GitHub Desktop.
Save elee/1015155 to your computer and use it in GitHub Desktop.
import os
import fnmatch
import re
coredir = '/etc/sv/core'
# with fnmatch
cores = [file for file in os.listdir(coredir) if fnmatch.fnmatch(file, 'core.*')]
# with re.compile
pattern = re.compile(r'core.[0-9]+')
cores2 = [file for file in os.listdir(coredir) if pattern.match(file)]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment