Last active
September 12, 2018 21:26
-
-
Save LukeMurphey/503817964ccd6b93ba81236b9c305f14 to your computer and use it in GitHub Desktop.
A script for making a file of a given size
This file contains 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
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