Advertisement
hackloper775

unix_python_linux

Jul 17th, 2013
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.69 KB | None | 0 0
  1. #!/usr/bin/env python3
  2.  
  3. from glob import glob
  4. from os import getcwd,path
  5. from sys import argv
  6.  
  7. wild = ""
  8. arg = ""
  9.  
  10. def wildcard(x,y):
  11.     mis_archivos = glob(x)
  12.     print ("Dir: %s" %(getcwd()))
  13.     if y == "-d":
  14.         for i in mis_archivos:
  15.             if path.isdir(i):
  16.                 print (i)
  17.     elif y == "-f":
  18.         for i in mis_archivos:
  19.             path.isfile(i)
  20.             print (i)
  21.     else:
  22.         for i in mis_archivos:
  23.             print (i)
  24. try:
  25.     wild = argv[1]
  26.     if argv[1] == "-d":
  27.         wild = argv[2]
  28.         arg = argv[1]
  29.     elif argv[1] == "-f":
  30.         wild = argv[2]
  31.         arg = argv[1]
  32.     wildcard(wild,arg)
  33. except IndexError:
  34.         print ("Uso:\n")
  35.         print ("opciones : -d (Directorios),-f (Ficheros)")
  36.         print ("%s [opciones] Wildcard" %(argv[0]))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement