Unix/Linux Go Back    


Shell Programming and Scripting BSD, Linux, and UNIX shell scripting — Post awk, bash, csh, ksh, perl, php, python, sed, sh, shell scripts, and other shell scripting languages questions here.

creating file of 1MB using shell command?

Shell Programming and Scripting


Tags
dd

Closed    
 
Thread Tools Search this Thread Display Modes
    #1  
Old Unix and Linux 03-29-2006
vijaya2006 vijaya2006 is offline
Registered User
 
Join Date: Feb 2006
Last Activity: 4 August 2010, 1:42 AM EDT
Posts: 27
Thanks: 0
Thanked 0 Times in 0 Posts
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!
Sponsored Links
    #2  
Old Unix and Linux 03-29-2006
vino's Unix or Linux Image
vino vino is offline Forum Advisor  
Supporter (in vino veritas)
 
Join Date: Feb 2005
Last Activity: 8 February 2016, 5:12 PM EST
Location: Sydney, Down Under
Posts: 2,848
Thanks: 0
Thanked 13 Times in 13 Posts
Try this.


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

It will be filled with /dev/zero's
Sponsored Links
    #3  
Old Unix and Linux 04-04-2006
vijaya2006 vijaya2006 is offline
Registered User
 
Join Date: Feb 2006
Last Activity: 4 August 2010, 1:42 AM EDT
Posts: 27
Thanks: 0
Thanked 0 Times in 0 Posts
Explaination clearly....

Hi Thanks for the reply....
I would like to be explained in detail
    #4  
Old Unix and Linux 04-04-2006
vino's Unix or Linux Image
vino vino is offline Forum Advisor  
Supporter (in vino veritas)
 
Join Date: Feb 2005
Last Activity: 8 February 2016, 5:12 PM EST
Location: Sydney, Down Under
Posts: 2,848
Thanks: 0
Thanked 13 Times in 13 Posts
Look into man dd. Or better yet info dd
Sponsored Links
    #5  
Old Unix and Linux 04-04-2006
matrixmadhan matrixmadhan is offline Forum Advisor  
Technorati Master
 
Join Date: Mar 2005
Last Activity: 10 January 2017, 8:10 AM EST
Location: classification algos
Posts: 3,215
Thanks: 19
Thanked 31 Times in 28 Posts
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 01:39 PM.. Reason: added code tags
Sponsored Links
Closed

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Linux More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
creating an executable file from shell scripts kokoro UNIX Desktop Questions & Answers 1 02-13-2012 08:15 PM
Creating File using the CAT Command Ravi Pavanv UNIX for Dummies Questions & Answers 7 01-12-2010 11:40 AM
Creating a command on a BASH shell hresquivelo Shell Programming and Scripting 4 08-06-2009 07:45 AM
Creating a command history feature in a simple UNIX shell using C -=Cn=- Shell Programming and Scripting 2 11-13-2007 12:04 AM
Help with a shell script for creating a log file heprox Shell Programming and Scripting 2 11-14-2006 01:00 AM



All times are GMT -4. The time now is 11:46 PM.