News for hackers. Stuff that matters.
Re:First steps with Scala, say goodbye to bash scripts… by icebraining on Thursday January 12, 2012 @06:49AM (#3455983)
Two nitpicks: grep by default returns lines that match, not files, you need the '-l' option; and you're passing the string "translated_files" to du instead of the actual files, you need just $translated_files instead of the echo.

And that breaks with files with spaces on them, which is a bane of shell scripts.

By the way, in Python:

    import os
    total_size = sum([os.path.getsize(filename) for filename in os.listdir('.')])
    matches = [match for match in os.listdir('.') if "todavida no ha sido traducida" in open(match).read()]
    translated_file_size = sum([os.path.getsize(filename) for filename in matches])
    print "translated size: %dKB/%dKB %d" % (translated_file_size, total_size, translated_file_size / total_size)
Re:First steps with Scala, say goodbye to bash scripts… by moonboots on Thursday January 12, 2012 @12:19PM (#3457089)
Good catches

The spaces in filenames can be handled by having grep and du communicate with null delimited strings instead of newline delimited, e.g.

  grep --files-with-matches --null "todavida..." *
  du --summarize --total --files-from=<($(echo $translated_file_size))