cancel
Showing results for 
Search instead for 
Did you mean: 
Trevor
Starfighter Starfighter
Starfighter
  • 121 Views

Create a Specific Size File

Jump to solution

What command can I use to create a file of a specific size?  
For example, if I want to create a 30M file, what command 
will allow me to do so?

 

 

Trevor "Red Hat Evangelist" Chandler
Labels (3)
0 Kudos
1 Solution

Accepted Solutions
TM
Flight Engineer Flight Engineer
Flight Engineer
  • 45 Views

The below command should do the trick.

dd if=/dev/zero count=1 bs=30M of=/tmp/file_with_specified_size

View solution in original post

4 Replies
TM
Flight Engineer Flight Engineer
Flight Engineer
  • 71 Views

Hi @Trevor ,

As I do not see the usual note "RHCE-level and below is the intended audience for this query!", can I share my answer ? Or a hint ?

Regards,

Tshimanga

Trevor
Starfighter Starfighter
Starfighter
  • 48 Views

TM, because of your courtesy and consideration,
I will gladly open the door for you to provide an
answer, or a hint!!!

Trevor "Red Hat Evangelist" Chandler
TM
Flight Engineer Flight Engineer
Flight Engineer
  • 46 Views

The below command should do the trick.

dd if=/dev/zero count=1 bs=30M of=/tmp/file_with_specified_size

Trevor
Starfighter Starfighter
Starfighter
  • 32 Views

Love the response TM!!!

Now, for that not-so-seasoned Linux person, I'd like to
pose a couple of separate questions, based on your
answer:

Question1:  For the output file (of=/tmp/....), you were
specific with the directory (/tmp) that the file would be
created, but generic with the name of the file (file_with...).
My question is, does the file HAVE TO BE created in the
/tmp directory? 

Question2:  Your use of count=1 and bs=30M, is certainly
acceptable. My question is, do I lose (or gain) anything if
I use either of the following combos of count and bs, instead
of the values that you used in your answer:

-   count=10  bs=3M
-   count=30 bs=1M


Thanks again TM!!!!

Trevor "Red Hat Evangelist" Chandler
0 Kudos
Join the discussion
You must log in to join this conversation.