# creating file of 1MB using shell command?

**URL:** <https://community.unix.com/t/creating-file-of-1mb-using-shell-command/160648>\
**Category:** Shell Programming and Scripting\
**Created:** [March 29, 2006, 4:17am UTC](https://community.unix.com/t/creating-file-of-1mb-using-shell-command/160648 "2006-03-29T04:17:36Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![vijaya2006](https://community.unix.com/letter_avatar/vijaya2006/32/6_22734026db12803ebb3e059622ac3534.png) [@vijaya2006](https://community.unix.com/u/vijaya2006)\
**Post date:** [March 29, 2006, 4:17am UTC](https://community.unix.com/t/creating-file-of-1mb-using-shell-command/160648/1 "2006-03-29T04:17:36Z")

</div>

Hi everybody in the forum,

I want to create an empty file of say some 1MB ,i mean at the command line itself.How is this possible??????EEK!

---

<div class="post-metadata">

**Author:** ![vino](https://community.unix.com/user_avatar/community.unix.com/vino/32/156_2.png) [@vino](https://community.unix.com/u/vino)\
**Post date:** [March 29, 2006, 4:35am UTC](https://community.unix.com/t/creating-file-of-1mb-using-shell-command/160648/2 "2006-03-29T04:35:20Z")

</div>

Try this.

```nohighlight
dd if=/dev/zero of=output.file bs=1024 count=1024

```

It will be filled with /dev/zero's

---

<div class="post-metadata">

**Author:** ![vijaya2006](https://community.unix.com/letter_avatar/vijaya2006/32/6_22734026db12803ebb3e059622ac3534.png) [@vijaya2006](https://community.unix.com/u/vijaya2006)\
**Post date:** [April 4, 2006, 5:51am UTC](https://community.unix.com/t/creating-file-of-1mb-using-shell-command/160648/3 "2006-04-04T05:51:17Z")

</div>

Hi Thanks for the reply....  
I would like to be explained in detail

---

<div class="post-metadata">

**Author:** ![vino](https://community.unix.com/user_avatar/community.unix.com/vino/32/156_2.png) [@vino](https://community.unix.com/u/vino)\
**Post date:** [April 4, 2006, 6:00am UTC](https://community.unix.com/t/creating-file-of-1mb-using-shell-command/160648/4 "2006-04-04T06:00:23Z")

</div>

Look into man dd. Or better yet info dd

---

<div class="post-metadata">

**Author:** ![matrixmadhan](https://community.unix.com/letter_avatar/matrixmadhan/32/6_22734026db12803ebb3e059622ac3534.png) [@matrixmadhan](https://community.unix.com/u/matrixmadhan)\
**Post date:** [April 4, 2006, 7:47am UTC](https://community.unix.com/t/creating-file-of-1mb-using-shell-command/160648/5 "2006-04-04T07:47:19Z")

</div>

> [@vino](#):
>
> Try this.
> 
> ```plaintext
> dd if=/dev/zero of=output.file bs=1024 count=1024
> 
> ```
> 
> It will be filled with /dev/zero's

this is just a suggestion,  
when generating files of huge size,  
it is better you attack from the block size thereby reducing the count

for a 1 MB file,

```plaintext
dd if=/dev/zero of=output.file bs=1024 count=1024

```

time taken = 0.13 s

```plaintext
dd if=/dev/zero of=output.file bs=1048576 count=1

```

time taken = 0.08 s  
it is just a difference of (0.13 - 0.08) s

but consider generating some 200 MB files  
attacking block size would surely provide a difference.
