Create a file of a specified size
Hey all,
Can anyone tell me if it is possible to create a file that is a certain size. I need to create a 50k and 200k file for testing and I can not for the life of me find a way to do it. Thank ya- |
Hi,
and welcome to LQ! Like so? Code:
dd if=/dev/zero of=50k_file bs=1024 count=50 Cheers, Tink |
Exactly like that.. Many thanks
|
Quote:
truncate -s the_size_you_want_to_the_very_byte filename SIZE may be (or may be an integer optionally followed by) one of following: KB 1000, K 1024, MB 1000*1000, M 1024*1024, and so on for G, T, P, E, Z, Y. Do man truncate. |
Quote:
Code:
dd if=/dev/random of=50k_file bs=1024 count=50 Depending on the test, an all-zeroes file may not provide accurate results. For instance, compression algorithm tests would have an absolute field day "compressing" all zeroes. So a random data file might be more to your liking. And to be thorough, I don't know how truncate handles the data when a file is grown. The man page does not mention whether the new space is all-zeroes, randomized, or "whatever was written at those particular sectors last time they were used." |
Quote:
|
All times are GMT -5. The time now is 02:18 PM. |