Skip to content

Instantly share code, notes, and snippets.

@LukeMurphey
Last active September 12, 2018 21:26
Show Gist options
  • Save LukeMurphey/503817964ccd6b93ba81236b9c305f14 to your computer and use it in GitHub Desktop.
Save LukeMurphey/503817964ccd6b93ba81236b9c305f14 to your computer and use it in GitHub Desktop.
A script for making a file of a given size
import sys
if len(sys.argv) != 3:
print 'Incorrect number of arguments; provide the file-name followed by the file-size.\ne.g. you can make a 1 GB file named "newfile" by calling:\n\n %s newfile 1073741824' % (sys.argv[0])
exit()
filename = sys.argv[1]
size = int(sys.argv[2])
with open(filename, "wb") as f:
f.seek(size - 1)
f.write(b"\0")
f.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment