creating file of 1MB using shell command?

Tags
dd, shell scripts

 
Thread Tools Search this Thread
# 1  
Old 03-29-2006
creating file of 1MB using shell command?

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!
# 2  
Old 03-29-2006
Try this.

Code:
dd if=/dev/zero of=output.file bs=1024 count=1024

It will be filled with /dev/zero's
# 3  
Old 04-04-2006
Explaination clearly....

Hi Thanks for the reply....
I would like to be explained in detail
# 4  
Old 04-04-2006
Look into man dd. Or better yet info dd
# 5  
Old 04-04-2006
Quote:
Originally Posted by vino
Try this.

Code:
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,
Code:
dd if=/dev/zero of=output.file bs=1024 count=1024

time taken = 0.13 s
Code:
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.

Last edited by Yogesh Sawant; 02-26-2010 at 02:39 PM.. Reason: added code tags

|
Thread Tools Search this Thread
Search this Thread:
Advanced Search

More UNIX and Linux Forum Topics You Might Find Helpful
Creating an excel file with filters using shell script. Marvin159875321 Shell Programming and Scripting 3 04-05-2018 04:32 AM
Creating file and passing argument to a command arunkumar_mca UNIX for Beginners Questions & Answers 1 02-03-2017 04:19 PM
Creating new users using a text file as imput (using only shell script and/or awk) marcosruiz Shell Programming and Scripting 2 05-15-2014 06:52 PM
Creating a Continuous File Reading-Executing Shell Script linuxlololol Shell Programming and Scripting 2 10-25-2013 07:19 AM
Shell Scripting for creating ftp and transfer file Preeti Saini Shell Programming and Scripting 13 08-12-2013 07:50 AM
Shell script for creating log file and sending mail? san_dy123 Shell Programming and Scripting 4 02-29-2012 06:01 AM
creating an executable file from shell scripts kokoro UNIX Desktop Questions & Answers 1 02-13-2012 09:15 PM
how to execute ksh simple shell script without creating .sh file Sooraj_Linux Shell Programming and Scripting 7 10-24-2011 07:40 AM
rename a file if it exceeds 1MB in size jamie_collins UNIX for Dummies Questions & Answers 4 02-25-2010 01:29 AM
Creating Report file with 'vlookup' kind of structure in shell vikaskm Shell Programming and Scripting 2 02-05-2010 04:36 AM
Creating File using the CAT Command Ravi Pavanv UNIX for Dummies Questions & Answers 7 01-12-2010 12:40 PM
Creating a command on a BASH shell hresquivelo Shell Programming and Scripting 4 08-06-2009 08:45 AM
Creating a file that contains output from a command, and then displays itself raidkridley UNIX for Dummies Questions & Answers 2 10-17-2008 01:30 AM
Creating a command history feature in a simple UNIX shell using C -=Cn=- Shell Programming and Scripting 2 11-13-2007 01:04 AM
Help with a shell script for creating a log file heprox Shell Programming and Scripting 2 11-14-2006 02:00 AM