Skip to content

Instantly share code, notes, and snippets.

@eduardocl
Created April 25, 2014 13:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eduardocl/11289269 to your computer and use it in GitHub Desktop.
Save eduardocl/11289269 to your computer and use it in GitHub Desktop.
import os
import subprocess
def executar(str):
''' Executa um comendo no shell retornando o stdout '''
args = str.split(' ')
p = subprocess.Popen(args, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
out, err = p.communicate()
return out
out = executar('find . -name *.java')
total = 0
for p in out.split('\n'):
if p.strip():
comando = 'wc -l {0}'.format(p.strip())
num,nome = executar(comando).split(' ')
total = total + int(num)
print "Total de linhas", total
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment