Last active
August 29, 2015 14:00
-
-
Save andrewspiers/901941302a0759c16fd4 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
import os | |
import sys | |
import time | |
purpose = "Print the age of a file rounded to the nearest second.\n" | |
usage = "Usage: " + sys.argv[0] + " <FILENAME>\n" | |
def fileage(f): | |
return int(round(time.time() - os.stat(f).st_mtime)) | |
if __name__ == "__main__": | |
try: | |
print (fileage(sys.argv[1])) | |
except IndexError: | |
sys.stderr.write(purpose + "\n" + usage) | |
sys.exit(1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment